Skip to content

Instantly share code, notes, and snippets.

@grantstephens
Last active March 20, 2020 16:03
Show Gist options
  • Save grantstephens/5102e521070e8002fa8822b42c447fd5 to your computer and use it in GitHub Desktop.
Save grantstephens/5102e521070e8002fa8822b42c447fd5 to your computer and use it in GitHub Desktop.
Golang Function to determine if a host is a valid IPv4 Address
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