Documentation
¶
Overview ¶
Package netip provides wrappers around net/netip types to implement the flag.Value interface. This allows these types to be used with the Go flag package for command-line flag parsing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Addr ¶
Addr wraps a netip.Addr to implement the flag.Value interface. It represents an IP address without a port.
func (*Addr) Set ¶
Set implements the flag.Value interface. Parses a string as an IP address and sets the Addr value. Returns an error if the string cannot be parsed or if the Addr is nil. An empty input string is treated as a no-op and returns nil.
type AddrPort ¶
AddrPort wraps a netip.AddrPort to implement the flag.Value interface. It represents an IP address and port number.
func (*AddrPort) Reset ¶
Reset sets the AddrPort to its zero value. Returns an error if the AddrPort is nil.
func (*AddrPort) Set ¶
Set implements the flag.Value interface. Parses a string in the format "ip:port" and sets the AddrPort value. Returns an error if the string cannot be parsed or if the AddrPort is nil. An empty input string is treated as a no-op and returns nil.
type Prefix ¶
Prefix wraps a netip.Prefix to implement the flag.Value interface. It represents an IP network with address and mask (CIDR notation).
func (*Prefix) Set ¶
Set implements the flag.Value interface. Parses a string in CIDR notation (e.g., "192.168.0.0/24") and sets the Prefix value. Returns an error if the string cannot be parsed or if the Prefix is nil. An empty input string is treated as a no-op and returns nil.
type PrefixList ¶
PrefixList wraps a slice of netip.Prefix to implement the flag.Value interface. It represents a list of IP networks specified in CIDR notation.
func ToPrefixList ¶
func ToPrefixList(p *[]netip.Prefix) *PrefixList
ToPrefixList creates a new PrefixList wrapper around a slice of netip.Prefix. This is a helper function to easily create a PrefixList from an existing slice.
func (*PrefixList) Reset ¶
func (p *PrefixList) Reset() error
Reset sets the PrefixList to nil. Returns an error if the PrefixList is nil.
func (*PrefixList) Set ¶
func (p *PrefixList) Set(s string) error
Set implements the flag.Value interface. Parses a comma-separated string of CIDR notations and sets the PrefixList value. Returns an error if any prefix cannot be parsed or if the PrefixList is nil. An empty input string is treated as a no-op and returns nil.
func (*PrefixList) Slice ¶
func (p *PrefixList) Slice() []string
Slice returns a slice of strings representing each prefix. Returns nil if the PrefixList is nil.
func (*PrefixList) String ¶
func (p *PrefixList) String() string
String returns a comma-separated string of all prefixes. Returns an empty string if the PrefixList is nil.
func (*PrefixList) Type ¶
func (p *PrefixList) Type() string
Type implements the flag.Value interface. Returns the type of the flag as a string.