Skip to content

ipgen/go

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

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.

Usage

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 (
  "fmt"
  "github.com/ipgen/go"
)

func main() {
  // Compute subnet ID
  subnet := ipgen.Subnet("App 1") 
  fmt.Println(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(ip) // output: fd52:f6b0:3162:46a1:2a4f:89e8:8aed:1327
}

About

Official implementation of the IPGen Spec in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages