Official implementation of the IPGen Spec in Go
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Go IPGen Library

Official implementation of the IPGen Spec in Go

IPGen is a library for generating unique and reproducible IP addresses in Go. The IP addresses generated by this library are highly unique (depending on your subnet prefix), yet if you pass it the same input it will produce the same IP address. You can also generate the IP addresses using our command line tool.


Using this library couldn't be simpler. It only exposes two functions, IP for generating IP addresses and Subnet for generating IPv6 subnet IDs.

Use it in your program as follows:-

package main

import (

fn main() {
  // Compute subnet ID
  subnet := ipgen.Subnet("App 1") 
  fmt.Println("%s", subnet) // output: ba3d
  // Or compute an IPv6 address
  // Note you can also pass in an IPv4 network to generate an IPv4
  ip, err := ipgen.IP("App 1", "fd52:f6b0:3162::/48")
  if err != nil {
    // Handle your error here
    // An error here means your network address is not valid
  fmt.Println("%s", ip) // output: fd52:f6b0:3162:46a1:2a4f:89e8:8aed:1327