-
Notifications
You must be signed in to change notification settings - Fork 12
Code Examples
Sean C Foley edited this page Jun 25, 2022
·
33 revisions
These are the Go code examples. You can also compare to the Java code examples.
Creating, Parsing, Extracting Address/Subnet Info
- Parse IP Address or Subnet String
- Parse IP Address String with Prefix Length as Subnet or IP Address
- Check if String is an IP Address or Host Name
- Parse Socket Address
- Convert to/from []byte, int, or big.Int
- Get Prefix Length, Network Mask, Network Address, Version, Subnet Size and Segments from CIDR Address or Subnet
- Check if Multicast
- Control Parsing of IP Addresses with Fewer Segments than Standard
Subnet or Range Containment and Matching
- Check if Subnet Contains Address or Subnet
- Check if Address or Subnet Falls within Arbitrary Address Range
- Select CIDR Prefix Block Subnets Containing an Address
- Select Addresses Contained by a CIDR Prefix Block Subnet
- Get Prefix Blocks Common to List of Addresses
- Longest Prefix Match
- Select Addresses and Subnets within Arbitrary Address Range
- Select Address Ranges Containing Arbitrary Address or Subnet
- Select CIDR Prefix Block Subnets Intersecting with Arbitrary Block
- Select Address Ranges Intersecting with Arbitrary Address Range
- Look up Associated IP Address Data by Containing Subnet or Matching Address
- Sort Addresses, Blocks and Ranges Collectively using Various Orderings
- Use Addresses as Keys for Go built-in maps
Subnetting and Other Subnet Operations
- Iterate through Subnet
- Iterate through Subnet Boundaries
- From Start and End Address, Get a Minimal List of CIDR Blocks Spanning the Range
- From Start and End Address, Get a Single CIDR Block Covering Both
- Merge a List of Addresses or Subnets into a Minimal List of CIDR Blocks
- Break a CIDR Prefix Block into Direct Component Blocks
- Iteratively Break a CIDR Prefix Block into Component Blocks
- Derive New Subnet from Existing CIDR Subnet
- Remove Address or Subnet from Subnet
- From Start and End Address, Get a Minimal List of Spanning Subnets, each with Segments either Single-Valued or Full-Range
Converting to/from Other Formats