Documentation
¶
Overview ¶
Package netiputil is a tiny utility package for a more relaxed representation of netip.AddrPort and netip.Addr datatypes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddrPortString ¶
AddrPortString returns the string form of the IP address addrp. It returns one of 5 forms, if port is zero:
- "", if addrp is the zero netip.AddrPort
- ":1337", if addrp.Addr() is the zero netip.Addr
- "192.0.2.1"
- "192.0.2.1:1337"
- "2001:db8::1"
- "[2001:db8::1]:1337"
- "::ffff:192.0.2.1"
- "[::ffff:192.0.2.1]:1337"
- "fe80:db8::1%eth0"
- "[fe80:db8::1%eth0]:1337"
func AddrString ¶
AddrString returns the string form of the IP address addr. It returns one of 5 forms:
- "", if addrp is the zero netip.Addr
- "192.0.2.1"
- "2001:db8::1"
- "::ffff:192.0.2.1"
- "fe80:db8::1%eth0"
Note that unlike the netip package, the zero addr is represented as an empty string.
func PortString ¶
PortString returns the string form of the port. It is either the empty string if the port is zero, or base 10 representation.
func StringAddr ¶
StringAddr parses a string into a netip.Addr. It accepts either of the following formats:
- "", for the zero netip.Addr
- "192.0.2.1"
- "2001:db8::1"
- "[2001:db8::1]"
- "::ffff:192.0.2.1"
- "[::ffff:192.0.2.1]"
- "fe80:db8::1%eth0"
- "[fe80:db8::1%eth0]"
func StringAddrPort ¶
StringAddrPort parses a string into a netip.AddrPort. It accepts either of the following formats:
- "", ":" or ":0", for the zero netip.AddrPort
- ":1337", for the zero netip.AddrPort with port 1337
- "192.0.2.1"
- "192.0.2.1:1337"
- "2001:db8::1"
- "[2001:db8::1]"
- "[2001:db8::1]:1337"
- "::ffff:192.0.2.1"
- "[::ffff:192.0.2.1]"
- "[::ffff:192.0.2.1]:1337"
- "fe80:db8::1%eth0"
- "[fe80:db8::1%eth0]"
- "[fe80:db8::1%eth0]:1337"
func StringPort ¶
StringPort parses a string into a uint16 port number. It accepts "" or "0" for the zero port, or base 10 representation.
Types ¶
This section is empty.