type IP … type IPNet … type ParseError … const IPv4len … const IPv6len … var CIDRMask … var IPv4 … // Parse IPv4 address (d.d.d.d). func parseIPv4(s string) IP { … } // parseIPv6 parses s as a literal IPv6 address described in RFC 4291 // and RFC 5952. func parseIPv6(s string) (ip IP) { … } // ParseIP parses s as an IP address, returning the result. // The string s can be in IPv4 dotted decimal ("192.0.2.1"), IPv6 // ("2001:db8::68"), or IPv4-mapped IPv6 ("::ffff:192.0.2.1") form. // If s is not a valid textual representation of an IP address, // ParseIP returns nil. func ParseIP(s string) IP { … } // ParseCIDR parses s as a CIDR notation IP address and prefix length, // like "192.0.2.0/24" or "2001:db8::/32", as defined in // RFC 4632 and RFC 4291. // // It returns the IP address and the network implied by the IP and // prefix length. // For example, ParseCIDR("192.0.2.1/24") returns the IP address // 192.0.2.1 and the network 192.0.2.0/24. func ParseCIDR(s string) (IP, *IPNet, error) { … } // This is copied from go/src/internal/bytealg, which includes versions // optimized for various platforms. Those optimizations are elided here so we // don't have to maintain them. func indexByteString(s string, c byte) int { … }