github.com/seancfoley/ipaddress-go/ipaddr (go): IPAddress is a library for handling IP addresses and subnets, both IPv4 and IPv6.  The primary goals are:  The core types are IPAddressString, HostName, and MACAddressString along with the Address base type and its associated types IPAddress, IPv4Address, IPv6Address, and MACAddress, as well as the sequential address type SequentialRange. If you have a textual representation of an IP address, then start with IPAddressString or HostName.  If you have a textual representation of a MAC address, then start with MACAddressString. Note that address instances can represent either a single address or a subnet. If you have either an address or host name, or you have something with a port or service name, then use HostName. If you have numeric bytes or integers, then start with IPv4Address, IPv6Address, IPAddress, or MACAddress.  This library allows you to scale down from more specific address types to more generic address types, and then to scale back up again. The polymorphism is useful for IP-version ambiguous code.  The most-specific types allow for method sets tailored to the address version or type. You can only scale up to a specific version or address type if the lower level instance was originally derived from an instance of the specific type. So, for instance, an IPv6Address can be converted to an IPAddress using IPv6Address.ToIP, or to an Address using IPv6Address.ToAddressBase, which can then be converted back to IPAddress or an IPv6Address using Address.ToIP or Address.ToIPv6. But that IPv6Address cannot be scaled back to IPv4.  If you wish to convert that IPv6Address to IPv4, you would need to use an implementation of IPv4AddressConverter.  This library has similarities in design to the Java IPAddress library. Notable divergences derive from the differences between the Java and Go languages, such as the differences in error handling and the lack of inheritance in Go, amongst many other differences. Other divergences derive from common Go language idioms and practices which differ from standard Java idioms and practices.  For common use-cases, you may wish to go straight to the wiki code examples which cover a wide breadth of common use-cases.  You can read further documentation with more depth.
Keywords: cidr|go|golang|golang-library|golang-module|golang-package|ip-address|ipaddress|ipv4|ipv4-address|ipv4-network|ipv4-subnetting|ipv6|ipv6-address|ipv6-network|ipv6-subnetting|mac-address|subnet|subnets|subnetting