# README
netaddr
A Go library for performing calculations on IPv4 and IPv6 subnets. There is also limited support for EUI addresses.
Installation
It should be noted that while the repository name is "netaddr-go" the package name is simply "netaddr".
go get github.com/dspinhirne/netaddr-go
Usage
package main
import "fmt"
import "github.com/dspinhirne/netaddr-go"
func main() {
net,_ := netaddr.ParseIPv4Net("192.168.1.0/24")
fmt.Println(net)
}
Documentation
Available online here.
Versioning
Versioning follows the standard documented here.
Why is there no 1.x.x? - I have chosen to match the versioning scheme of the original Ruby library. Following this, the API of this code is similar to that of the Ruby code.
# Functions
IPv4PrefixLen returns the prefix length needed to hold the number of IP addresses specified by "size".
NewIPv4 creates an IPv4 type from a uint32.
NewIPv4List parses a slice of IPv4 addresses into a IPv4List.
NewIPv4Net creates a IPv4Net type from a IPv4 and Mask32.
NewIPv4NetList parses a slice of IP networks into a IPv4NetList.
NewIPv6 creates an IPv6 type from a pair of uint64.
NewIPv6List parses a slice of IPv6 addresses into a IPv6List.
NewIPv6Net creates a IPv6Net type from a IPv6 and Mask128.
NewIPv6NetList parses a slice of IP networks into a IPv6NetList.
NewMask128 converts an integer, representing the prefix length for an IPv6 network, to a Mask128 type.
NewMask32 converts an integer, representing the prefix length for an IPv4 address, to a Mask32 type.
Parse an EUI-48 string into an EUI48 type.
Parse an EUI-64 string into an EUI64 type.
ParseIP parses a string into an IP.
ParseIPNet parses a string into an IPNet.
ParseIPv4 parses a string into an IPv4 type.
ParseIPv4Net parses a string into an IPv4Net type.
ParseIPv6 arses a string into an IPv6 type.
ParseIPv6Net parses a string into an IPv6Net type.
ParseMask128 parses a prefix length string to a Mask128 type.
ParseMask32 parses an IPv4 netmask or prefix length string to a Mask32 type.
# Type aliases
EUI48 (Extended Unique Identifier 48-bit, or EUI-48) represents a 48-bit hardware address.
EUI64 (Extended Unique Identifier 64-bit, or EUI-64) represents a 64-bit hardware address.
IPv4List is a slice of IPv4 types.
IPv4NetList is a slice of IPv4 types.
IPv6List is a slice of IPv6 types.
IPv6NetList is a slice of IPv6 types.