---
source: https://iinventedlight.com/library/notes/go-net-netip.md
title: "Go net/netip: a small comparable IP address type"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (Go); BSD-3-Clause (Go); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Go, net/netip package reference; Go, net/netip source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: go-net-netip"
tags: [go, netip, ip, addr, prefix]
client: Librarian
sources:
  - id: S1
    title: "net/netip package reference"
    publisher: Go
    url: https://pkg.go.dev/net/netip
    accessed: 2026-11-23
    license: "BSD-3-Clause"
  - id: S2
    title: "net/netip source"
    publisher: Go
    url: https://go.dev/src/net/netip/netip.go
    accessed: 2026-11-23
    license: "BSD-3-Clause"
---
# Go net/netip: a small comparable IP address type
**Answer:** Package netip defines an IP address type that's a small value type.

## Addr, AddrPort, and Prefix

The Addr type is a small value type.

AddrPort combines an IP address and a port.

Prefix combines an IP address and a bit length prefix.

## Why Addr differs from net IP

Compared with the older net IP type, Addr takes less memory.

Addr is also immutable and comparable, so it can be a map key.

The zero Addr is not a valid IP address.

## See also

- [go-net-url](https://iinventedlight.com/library/notes/go-net-url/)
- [go-net-dial-listen](https://iinventedlight.com/library/notes/go-net-dial-listen/)
- [go-net-http-client](https://iinventedlight.com/library/notes/go-net-http-client/)

## Claims

- id: C1
  claim: The package defines a small value type for IP addresses.
  source: S1
  evidence: "an IP address type that's a small value type"

- id: C2
  claim: AddrPort pairs an address with a port.
  source: S1
  evidence: "AddrPort (an IP address and a port)"

- id: C3
  claim: Addr takes less memory and is immutable.
  source: S2
  evidence: "takes less memory, is immutable,"

- id: C4
  claim: The zero Addr is not a valid IP address.
  source: S2
  evidence: "The zero Addr is not a valid IP address."

## Sources

- [S1] net/netip package reference. Go. https://pkg.go.dev/net/netip . License: BSD-3-Clause. Accessed 2026-11-23.

- [S2] net/netip source. Go. https://go.dev/src/net/netip/netip.go . License: BSD-3-Clause. Accessed 2026-11-23.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Go, net/netip package reference; Go, net/netip source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
