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) IP

Parameters & Attributes

NameTypeDescription
abyteFirst address octet.
bbyteByte buffer, binary representation or prefix length as indicated by its type.
cbyteThird address octet.
dbyteFourth 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)  }}
Go Reference