Last active
March 20, 2020 16:03
-
-
Save grantstephens/5102e521070e8002fa8822b42c447fd5 to your computer and use it in GitHub Desktop.
Golang Function to determine if a host is a valid IPv4 Address
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
func IsIPv4Net(host string) bool { | |
valid := net.ParseIP(host) != nil | |
if valid { | |
return !strings.ContainsRule(host, ':') | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment