Skip to content
/ go Public

Official implementation of the IPGen Spec in Go

License

Notifications You must be signed in to change notification settings

ipgen/go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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