Skip to content

Instantly share code, notes, and snippets.

@ivan3bx
Created February 1, 2020 15:49
Show Gist options
  • Save ivan3bx/9de66dfbf8ce12efcc59fa6eceae8f1a to your computer and use it in GitHub Desktop.
Save ivan3bx/9de66dfbf8ce12efcc59fa6eceae8f1a to your computer and use it in GitHub Desktop.
retrieve subnet for given IP
package main
import (
"net"
"fmt"
)
// Get the subnet for a given IP address
func geoIP() {
ip := net.ParseIP("128.174.5.59")
ipv4Mask := net.CIDRMask(24, 32)
fmt.Println(ip.Mask(ipv4Mask))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment