Created
February 1, 2020 15:49
-
-
Save ivan3bx/9de66dfbf8ce12efcc59fa6eceae8f1a to your computer and use it in GitHub Desktop.
retrieve subnet for given IP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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