Skip to content

A library handling IP addresses like ipaddress-gem/ipaddress.

License

Notifications You must be signed in to change notification settings

worbridg/ipaddress

Repository files navigation

ci go-referrence

ipaddress

A library handling IP addresses like ipaddress-gem/ipaddress.

Example

import (
    "fmt"

    "github.com/worbridg/ipaddress"
)

func main() {
    ipv4, _ := ipaddress.NewIPv4Address("192.168.0.1/24")
    fmt.Println(ipv4, ipv4.Network(), ipv4.Broadcast(), ipv4.IsPrivate(), ipv4.Netmask())
    // Output: 192.168.0.1, 192.168.0.0, 192.168.0.255, true, 255.255.255.0
    fmt.Println(ipv4.ARPA())
    // Output: 1.0.168.192.in-addr.arpa
    fmt.Println(ipv4.Sample(), ipv4.Sample())
    // Output: 192.168.0.33, 192.168.0.199
}

Installation

$ go get github.com/worbridg/ipaddress

LICENSE

MIT

Author

worbridg

About

A library handling IP addresses like ipaddress-gem/ipaddress.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages