RepositoryGo
SE

seancfoley/ipaddress-go

Go library for handling IP addresses and subnets, both IPv4 and IPv6

118stars
14forks
0issues
2views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: ipv6-network

#1 Repository of the week

1
TINIX TRENDING·Topic: subnet

#1 Repository of the week

1
TINIX TRENDING·Topic: ip-address

#1 Repository of the week

ipaddress-go

Go library for handling IP addresses and subnets, both IPv4 and IPv6

IP address and network manipulations, CIDR, address and subnet operations, address ranges, iterators, containment checks, longest prefix match, subnetting, address tries, address collections, and more, with polymorphic code

Docs Site

Godoc Go Reference

Code Examples

List of Users

VersionNotes
1.2.1Requires Go 1.12 or higher
1.4.1Requires Go 1.13 or higher
1.7.1Requires Go 1.18 or higher

In your go.mod file:
require github.com/seancfoley/ipaddress-go v1.7.1

In your source file:
import "github.com/seancfoley/ipaddress-go/ipaddr"

Packaged as a Linux Fedora rpm and as a Linux Debian, available from Ubuntu

Also available as a Java library from the IPAddress repository

Getting Started

starting with address or subnet strings

import "github.com/seancfoley/ipaddress-go/ipaddr"

ipv6AddrStr := ipaddr.NewIPAddressString("a:b:c:d::a:b/64")
if ipAddr, err := ipv6AddrStr.ToAddress(); err != nil {
	// err.Error() has validation error
} else {
	// use the address
}

...or avoid errors, checking for nil:

str := ipaddr.NewIPAddressString("a:b:c:d:e-f:f:1.2-3.3.4/64")
addr := str.GetAddress()
if addr != nil {
	// use address
}

starting with host name strings

hostStr := "[::1]"

host := ipaddr.NewHostName(hostStr)
err := host.Validate()
if err == nil {
	if host.IsAddress() {
		fmt.Println("address: " + host.AsAddress().String())
	} else {
		fmt.Println("host name: " + host.String())
	}
	// use host
} else {
	fmt.Println(err.Error())
}

Similar Projects

Discover other similar projects and AI models.

RepositoryGo
3th1nk/cidr

Go library for CIDR: parse, sort, split & merge IP segments, overlap/subnet checks, collapse & range ops, host & mask math, netip interop (IPv4/IPv6)

95
Sep 29, 2026
RepositoryGo
avelino/awesome-go

A curated list of awesome Go frameworks, libraries and software

197.2k
Dec 2, 2026
RepositoryGo
ollama/ollama

Get up and running with Inkling, Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

188.9k
Dec 2, 2026
RepositoryHTML
itbdw/ip-database

免费IP离线数据库,支持IPV4+IPV6 ,国家、省、市、县、运营商

1.5k
Dec 1, 2023
RepositoryTypeScript
beaugunderson/ip-address

💻 a library for parsing and manipulating IPv4 and IPv6 addresses in JavaScript

636
Nov 28, 2026
RepositoryC#
lduchosal/ipnetwork

IPNetwork command line and C# library take care of complex network, IP, IPv4, IPv6, netmask, CIDR, subnet, subnetting, supernet, and supernetting calculation for .NET developers. It works with IPv4 as well as IPv6, is written in C#, has a light and clean API, and is fully unit-tested

526
Nov 16, 2026
RepositoryC
blechschmidt/freebind

IPv6 address rate limiting evasion tool (that also supports IPv4)

294
Dec 15, 2023
RepositoryPHP
markrogoyski/ipv4-subnet-calculator-php

PHP library for IPv4 subnet calculations, CIDR operations, and network planning.

175
Nov 10, 2026
RepositoryGo
golang/go

The Go programming language

140.0k
Dec 1, 2026