8 // IPOpt holds an IP. It is used to store values from CLI flags.
13 // NewIPOpt creates a new IPOpt from a reference net.IP and a
14 // string representation of an IP. If the string is not a valid
15 // IP it will fallback to the specified reference.
16 func NewIPOpt(ref *net.IP, defaultVal string) *IPOpt {
24 // Set sets an IPv4 or IPv6 address from a given string. If the given
25 // string is not parseable as an IP address it returns an error.
26 func (o *IPOpt) Set(val string) error {
27 ip := net.ParseIP(val)
29 return fmt.Errorf("%s is not an ip address", val)
35 // String returns the IP address stored in the IPOpt. If stored IP is a
36 // nil pointer, it returns an empty string.
37 func (o *IPOpt) String() string {