Standard library / net
net.IPv4()
Construct an IPv4 address in net.IP representation (16 bytes). Expected stdout: '192.0.2.7\n'.
Formal Syntax & Structure
go syntaxgo
func IPv4(a, b, c, d byte) IPParameters & Attributes
| Name | Type | Description |
|---|---|---|
| a | byte | First address octet. |
| b | byte | Byte buffer, binary representation or prefix length as indicated by its type. |
| c | byte | Third address octet. |
| d | byte | Fourth address octet. |
Return Value
IP
Operation result; check errors and validity indicators when returned.
Working Example
Example Snippetgo
package main
import ( "fmt" "net")
func main() { fmt.Println(net.IPv4(192, 0, 2, 7)) }
func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}