package check import ( "time" "github.com/sparrc/go-ping" ) //ICMPPing returns the ping to the target host. func ICMPPing(targetHost string) (time.Duration, Result, error) { pinger, err := ping.NewPinger(targetHost) if err != nil { return 0, Offline, err } pinger.Count = TryCount pinger.Run() stats := pinger.Statistics() return stats.AvgRtt, statusFromSuccessCount(stats.PacketsRecv), nil }