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.
|
package tcping
|
|
|
|
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 ""
|
|
}
|