You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Go package for handling IP addresses and subnets. IPv4 and IPv6.
Working with IP addresses and networks, CIDR, address and subnet operations, iterations, content checks, IP to CIDR block lookup, longest prefix match, creating subnets, spanning, merging, ranges and address tries, with polymorphic code
Usage
starting with address or subnet strings
import"github.com/pchchv/goip"ipv6AddrStr:=goip.NewIPAddressString("a:b:c:d::a:b/64")ifipAddr,err:=ipv6AddrStr.ToAddress();err!=nil {// error validation}else {// use the address}
...or checking for nil:
str:=goip.NewIPAddressString("a:b:c:d:e-f:f:1.2-3.3.4/64")addr:=str.GetAddress()ifaddr!=nil {// use address}
starting with host name:
hostStr:="[::1]"host:=goip.NewHostName(hostStr)iferr:=host.Validate();err!=nil {panic(err)}// use hostifhost.IsAddress() {fmt.Println("address: "+host.AsAddress().String())}else {fmt.Println("host name: "+host.String())}