{"id":13413502,"url":"https://github.com/osamingo/gosh","last_synced_at":"2025-05-12T13:24:31.520Z","repository":{"id":55122741,"uuid":"134830868","full_name":"osamingo/gosh","owner":"osamingo","description":"Provide Go Statistics Handler, Struct, Measure Method","archived":false,"fork":false,"pushed_at":"2025-03-22T15:14:55.000Z","size":32,"stargazers_count":35,"open_issues_count":0,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-20T13:36:21.613Z","etag":null,"topics":["api","go","golang","handler","metrics","monitoring","statistics","stats"],"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/osamingo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"osamingo","custom":"https://paypal.me/osamingo"}},"created_at":"2018-05-25T08:55:55.000Z","updated_at":"2025-03-22T13:52:06.000Z","dependencies_parsed_at":"2023-11-09T13:04:19.035Z","dependency_job_id":"3d6372d0-8bf4-4dc4-acb9-2dfd589b81b1","html_url":"https://github.com/osamingo/gosh","commit_stats":{"total_commits":44,"total_committers":1,"mean_commits":44.0,"dds":0.0,"last_synced_commit":"d780c99cb9786749be60869733ce81fdc993662c"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osamingo%2Fgosh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osamingo%2Fgosh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osamingo%2Fgosh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osamingo%2Fgosh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/osamingo","download_url":"https://codeload.github.com/osamingo/gosh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745841,"owners_count":21957452,"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":["api","go","golang","handler","metrics","monitoring","statistics","stats"],"created_at":"2024-07-30T20:01:41.804Z","updated_at":"2025-05-12T13:24:31.493Z","avatar_url":"https://github.com/osamingo.png","language":"Go","readme":"# Go Statistics Handler\n\n[![CI](https://github.com/osamingo/gosh/actions/workflows/actions.yml/badge.svg)](https://github.com/osamingo/gosh/actions/workflows/actions.yml)\n[![codecov](https://codecov.io/gh/osamingo/gosh/branch/master/graph/badge.svg)](https://codecov.io/gh/osamingo/gosh)\n[![Go Report Card](https://goreportcard.com/badge/github.com/osamingo/gosh)](https://goreportcard.com/report/github.com/osamingo/gosh)\n[![GoDoc](https://godoc.org/github.com/osamingo/gosh?status.svg)](https://godoc.org/github.com/osamingo/gosh)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/osamingo/gosh/master/LICENSE)\n\n## About\n\n- The `gosh` is an abbreviation for Go Statistics Handler.\n- This Repository is provided following functions.\n  - Go runtime statistics struct.\n  - Go runtime statistics API handler.\n  - Go runtime measure method.\n- You can specify the favorite JSON encoder.\n  - [`encoding/json`](https://pkg.go.dev/encoding/json/) package.\n  - [`goccy/go-json`](https://pkg.go.dev/github.com/goccy/go-json) package.\n  - The original package you created, and so on.\n\n## Install\n\n```bash\n$ go get github.com/osamingo/gosh@latest\n```\n\n## Usage\n\n### Example\n\n```go\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"io\"\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/osamingo/gosh\"\n)\n\nfunc main() {\n\n\th, err := gosh.NewStatisticsHandler(func(w io.Writer) gosh.JSONEncoder {\n\t\treturn json.NewEncoder(w)\n\t})\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\n\tmux := http.NewServeMux()\n\tmux.Handle(\"/healthz\", h)\n\n\tif err := http.ListenAndServe(\":8080\", mux); err != nil {\n\t\tlog.Fatalln(err)\n\t}\n}\n```\n\n### Output\n\n```bash\n$ curl \"localhost:8080/healthz\" | jq .\n{\n  \"timestamp\": 1527317620,\n  \"go_version\": \"go1.10.2\",\n  \"go_os\": \"darwin\",\n  \"go_arch\": \"amd64\",\n  \"cpu_num\": 8,\n  \"goroutine_num\": 6,\n  \"gomaxprocs\": 8,\n  \"cgo_call_num\": 1,\n  \"memory_alloc\": 422272,\n  \"memory_total_alloc\": 422272,\n  \"memory_sys\": 3084288,\n  \"memory_lookups\": 6,\n  \"memory_mallocs\": 4720,\n  \"memory_frees\": 71,\n  \"stack_inuse\": 491520,\n  \"heap_alloc\": 422272,\n  \"heap_sys\": 1605632,\n  \"heap_idle\": 401408,\n  \"heap_inuse\": 1204224,\n  \"heap_released\": 0,\n  \"heap_objects\": 4649,\n  \"gc_next\": 4473924,\n  \"gc_last\": 0,\n  \"gc_num\": 0,\n  \"gc_per_second\": 0,\n  \"gc_pause_per_second\": 0,\n  \"gc_pause\": []\n}\n```\n\n\n## License\n\nReleased under the [MIT License](https://github.com/osamingo/gosh/blob/master/LICENSE).\n","funding_links":["https://github.com/sponsors/osamingo","https://paypal.me/osamingo"],"categories":["Miscellaneous","杂项","其他杂项","其他","Microsoft Office","Uncategorized"],"sub_categories":["Uncategorized","未分类的","暂未分类","交流","Strings","暂未分类这些库被放在这里是因为其他类别似乎都不适合。","Advanced Console UIs"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosamingo%2Fgosh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fosamingo%2Fgosh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosamingo%2Fgosh/lists"}