Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
It is not possible to do this in the standard library, you can use this: https://github.com/tatsushid/go-fastping
Note that sending ICMP packets requires root privileges
https://godoc.org/golang.org/x/net/ icmp
https://en.wikipedia.org/wiki/Internet_Control_Mes...
this is not a 100% method to ping other servers because admins often disable ping due to security reasons
out, _ := exec.Command("ping", "192.168.0.111", "-c 5", "-i 3", "-w 10").Output()
if strings.Contains(string(out), "Destination Host Unreachable") {
fmt.Println("TANGO DOWN")
} else {
fmt.Println("IT'S ALIVEEE")
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question