{"id":19285977,"url":"https://github.com/chenjiandongx/pinger","last_synced_at":"2025-08-21T07:08:56.402Z","repository":{"id":48570801,"uuid":"261667977","full_name":"chenjiandongx/pinger","owner":"chenjiandongx","description":"📌 A portable ping library written in Go","archived":false,"fork":false,"pushed_at":"2024-05-27T11:57:59.000Z","size":1211,"stargazers_count":58,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-31T07:41:41.881Z","etag":null,"topics":["ping","pinger"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chenjiandongx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-06T06:10:27.000Z","updated_at":"2025-03-06T13:02:57.000Z","dependencies_parsed_at":"2022-09-04T05:52:50.178Z","dependency_job_id":null,"html_url":"https://github.com/chenjiandongx/pinger","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenjiandongx%2Fpinger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenjiandongx%2Fpinger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenjiandongx%2Fpinger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenjiandongx%2Fpinger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chenjiandongx","download_url":"https://codeload.github.com/chenjiandongx/pinger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252834248,"owners_count":21811342,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ping","pinger"],"created_at":"2024-11-09T21:47:34.696Z","updated_at":"2025-05-07T07:35:25.844Z","avatar_url":"https://github.com/chenjiandongx.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pinger\n\n\u003e 📌 A portable ping library written in Go.\n\nPinger is a library used to evaluate the quality of services in ICMP/TCP/HTTP protocol.\n\nWhat's worth pointing out is that `ping` here means not only the standard **ICMP Protocol**, but also **TCP/HTTP/HTTPS**. It's the more general sense here as an approach to detect the network quality.\n\n[![GoDoc](https://godoc.org/github.com/chenjiandongx/pinger?status.svg)](https://godoc.org/github.com/chenjiandongx/pinger)\n[![Travis](https://travis-ci.org/chenjiandongx/pinger.svg?branch=master)](https://travis-ci.org/chenjiandongx/pinger)\n[![Appveyor](https://ci.appveyor.com/api/projects/status/v7w3u0p66grbfpxb/branch/master?svg=true)](https://ci.appveyor.com/project/chenjiandongx/pinger/branch/master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/chenjiandongx/pinger)](https://goreportcard.com/report/github.com/chenjiandongx/pinger)\n[![License](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)\n\n### 🔰 Installation\n\n```shell\n$ go get -u github.com/chenjiandongx/pinger\n```\n\n### 📝 Basic Usage\n\n```golang\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/chenjiandongx/pinger\"\n)\n\nfunc main() {\n\t// ICMP\n\tstats, err := pinger.ICMPPing(nil, \"huya.com\", \"youtube.com\", \"114.114.114.114\")\n\n\t// TCP\n\t// stats, err := pinger.TCPPing(nil, \"huya.com:80\", \"google.com:80\", \"huya.com:443\", \"google.com:443\")\n\n\t// HTTP/HTTPS\n\t// stats, err := pinger.HTTPPing(nil, \"http://huya.com\", \"https://google.com\", \"http://39.156.69.79\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfor _, s := range stats {\n\t\tfmt.Printf(\"%+v\\n\", s)\n\t}\n}\n\n// output\n{Host:huya.com PktSent:10 PktLossRate:0 Mean:36.217604ms Last:37.636144ms Best:34.949608ms Worst:37.636144ms}\n{Host:youtube.com PktSent:10 PktLossRate:0 Mean:12.853867ms Last:13.105932ms Best:11.836598ms Worst:14.844776ms}\n{Host:114.114.114.114 PktSent:10 PktLossRate:0 Mean:7.689701ms Last:7.711122ms Best:6.252377ms Worst:9.427482ms}\n```\n\n### 🎉 Options\n\n**PingTimeout / Interval**\n```golang\nopts := pinger.DefaultICMPPingOpts()\nopts.PingTimeout = 50 * time.Millisecond\n// sleep 60 mills after a request every time.\nopts.Interval = func() time.Duration { return 60 * time.Millisecond }\n```\n\n**PingCount / MaxConcurrency / FailOver**\n```golang\nopts := pinger.DefaultICMPPingOpts()\n// network is unstable thus we need more ping-ops to evaluate the network quality overall.\nopts.PingCount = 20\n// set the maximum concurrency, goroutine is cheap, but not free :)\nopts.MaxConcurrency = 5\n// set per host maximum failed allowed\nopts.FailOver = 5\n```\n\n**Headers / Method**\n```golang\n// in http/https case, there are more options could be used.\nopts := pinger.DefaultHTTPPingOpts()\n// HTTP headers, something special for authentication or anything else.\nopts.Headers = map[string]string{\"token\": \"my-token\", \"who\": \"me\"}\n// HTTP Method, feel free to use any standard HTTP methods you need.\nopts.Method = http.MethodPost\n```\n\n*For more information, please refer to [the documentation](https://godoc.org/github.com/chenjiandongx/pinger).*\n\n### 📃 License\n\nMIT [©chenjiandongx](https://github.com/chenjiandongx)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenjiandongx%2Fpinger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchenjiandongx%2Fpinger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenjiandongx%2Fpinger/lists"}