Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

inetaf/netaddr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

May 25, 2023
b8eac61 · May 25, 2023
Sep 3, 2021
Jun 2, 2021
Sep 3, 2021
Dec 29, 2020
Apr 14, 2021
Jun 2, 2021
Mar 30, 2020
Aug 11, 2022
Jul 21, 2021
Sep 3, 2021
May 25, 2023
May 25, 2023
Jun 17, 2022
Jul 21, 2021
Jul 18, 2021
Jan 15, 2021
Oct 22, 2021
Jul 21, 2021
Dec 31, 2020
Sep 3, 2021
Jan 15, 2021
Jan 5, 2021

Repository files navigation

netaddr Test Status Go Reference

Deprecated

Please see https://pkg.go.dev/go4.org/netipx and the standard library's net/netip.

What

This is a package containing a new IP address type for Go.

See its docs: https://pkg.go.dev/inet.af/netaddr

Status

This package is mature, optimized, and used heavily in production at Tailscale. However, API stability is not yet guaranteed.

netaddr is intended to be a core, low-level package. We take code review, testing, dependencies, and performance seriously, similar to Go's standard library or the golang.org/x repos.

Motivation

See https://tailscale.com/blog/netaddr-new-ip-type-for-go/ for a long blog post about why we made a new IP address package.

Other links:

  • golang/go#18804 ("net: reconsider representation of IP")
  • golang/go#18757 ("net: ParseIP should return an error, like other Parse functions")
  • golang/go#37921 ("net: Unable to reliably distinguish IPv4-mapped-IPv6 addresses from regular IPv4 addresses")
  • merges net.IPAddr and net.IP (which the Go net package is a little torn between for legacy reasons)

Testing

In addition to regular Go tests, netaddr uses fuzzing. The corpus is stored separately, in a submodule, to minimize the impact on everyone else.

To use:

$ git submodule update --init
$ go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build
$ go-fuzz-build && go-fuzz