# Pinger Pinger is a library used to evaluate the quality of services in ICMP/TCP/HTTP protocol. ### ???? Installation ```shell $ go get -u github.com/chenjiangdongx/pinger ``` ### ???? Usage > Here is an example. For more information, please refer to [godoc](https://godoc.org/github.com/chenjiandongx/pinger). ```golang package main import ( "fmt" "github.com/chenjiandongx/pinger" ) func main() { // ICMP stats, err := pinger.ICMPPing(nil, "qq.com", "baidu.com", "114.114.114.114") // TCP // stats, err := pinger.TCPPing(nil, "baidu.com:80", "qq.com:80", "qq.com:443", "baidu.com:443") // HTTP/HTTPS // stats, err := pinger.HTTPPing(nil, "http://baidu.com", "https://baidu.com", "http://39.156.69.79") if err != nil { panic(err) } for _, s := range stats { fmt.Printf("%+v\n", s) } } // output {Host:qq.com PktSent:10 PktLossRate:0 Mean:42.858058ms Last:39.66054ms Best:38.031497ms Worst:71.050511ms} {Host:baidu.com PktSent:10 PktLossRate:0 Mean:45.834938ms Last:44.408987ms Best:40.155878ms Worst:75.480914ms} {Host:114.114.114.114 PktSent:10 PktLossRate:0 Mean:10.953486ms Last:6.618554ms Best:5.407619ms Worst:38.53662ms} ``` 项目地址:https://github.com/chenjiandongx/pinger
有疑问加站长微信联系(非本文作者))
