You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Victorique/vtqe/tools/ping/fqdn.go

18 lines
261 B
Go

package ping
import "net"
// GetIP ...
func GetIP(hostname string) string {
addrs, err := net.LookupIP(hostname)
if err != nil {
return ""
}
for _, addr := range addrs {
if ipv4 := addr.To4(); ipv4 != nil {
return ipv4.String()
}
}
return ""
}