Skip to content

Instantly share code, notes, and snippets.

@bdss58
Created January 15, 2019 07:50
Show Gist options
  • Save bdss58/9453bdb240b94620ee1394baa44e9713 to your computer and use it in GitHub Desktop.
Save bdss58/9453bdb240b94620ee1394baa44e9713 to your computer and use it in GitHub Desktop.
ip 字符串转整型 (golang)
func ip2int(ip string) uint32 {
IP := net.ParseIP(ip)
if len(IP) >= 16 {
return binary.BigEndian.Uint32(IP[12:16])
} else {
return 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment