Documentation ¶
Overview ¶
Package ipnetgen provides a way to iterate over the addresses in a subnet:
gen, err := New("192.168.100.0/24") if err != nil { //do something with err } for ip := gen.Next(); ip != nil; ip = gen.Next() { //do something with ip }
ipnetgen works on net.IPs, meaning it supports both IPv4 and IPv6 addresses.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type IPNetGenerator ¶
IPNetGenerator is a net.IPnet wrapper that you can iterate over
func New ¶
func New(cidr string) (*IPNetGenerator, error)
New creates a new IPNetGenerator from a CIDR string, or an error if the CIDR is invalid.
func NewFromIPNet ¶
func NewFromIPNet(ipNet *net.IPNet) *IPNetGenerator
NewFromIPNet creates a new IPNetGenerator from a *net.IPNet
func (*IPNetGenerator) Next ¶
func (g *IPNetGenerator) Next() net.IP
Next returns the next net.IP in the subnet
Click to show internal directories.
Click to hide internal directories.