Skip to content
/ pinger Public
forked from chenjiandongx/pinger

📌 A portable ping library written in Go

License

Notifications You must be signed in to change notification settings

danl5/pinger

 
 

Repository files navigation

Pinger

📌 A portable ping library written in Go.

Pinger is a library used to evaluate the quality of services in ICMP/TCP/HTTP protocol.

GoDoc Travis Appveyor Go Report Card License

🔰 Installation

$ go get -u github.com/chenjiandongx/pinger

📝 Usage

Here is an example. For more information, please refer to godoc.

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}

📃 License

MIT ©chenjiandongx

About

📌 A portable ping library written in Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%