Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Go library for handling IP addresses and subnets

License

NotificationsYou must be signed in to change notification settings

pchchv/goip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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())}

[8]ページ先頭

©2009-2025 Movatter.jp