pingo a a Go package to do ICMP pings (send ICMP echo and wait for a reply). You can do it with IPv4 and IPv6.
WARNING : to use pingo you need root privileges.
go get github.com/samonzeweb/pingo
package main
import (
"fmt"
"os"
"time"
"github.com/samonzeweb/pingo"
)
func main() {
if len(os.Args) != 2 {
fmt.Println("Please give a hostname as argument")
os.Exit(1)
}
t, err := pingo.SimplePing(os.Args[1], pingo.IP, time.Second)
if err != nil {
if err == pingo.ErrTimeOut {
fmt.Printf("Time out : %v\n", err)
os.Exit(1)
}
fmt.Printf("Error : %v\n", err)
os.Exit(1)
}
fmt.Printf("Got a response from %s, in %d ms\n", os.Args[1], t/time.Millisecond)
}
The pingo package depends on GoConvey. Simply install all the necessary things with :
go get -t
The tests are naives. Testing some cases need disabling network card, changing routes, ... It's really hard to automate but easy to do manually if needed.
WARNING : Travis CI does not support IPv6. Only IPv4 tests are run on Travis CI.
Released under the MIT License, see LICENSE.txt
for more informations.