ipgen

package module
v0.0.0-...-077d420 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2021 License: MIT Imports: 3 Imported by: 1

README

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
}

Documentation

Overview

This library is the official implementation of the IPGen Spec

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IP

func IP(name, cidr string) (ip net.IP, err error)

Generates an IP address

func Subnet

func Subnet(name string) string

Generates an IPv6 subnet ID

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL