{"id":13480991,"url":"https://github.com/uber-go/goleak","last_synced_at":"2025-05-13T19:13:18.375Z","repository":{"id":37334569,"uuid":"109330128","full_name":"uber-go/goleak","owner":"uber-go","description":"Goroutine leak detector","archived":false,"fork":false,"pushed_at":"2024-11-21T20:38:38.000Z","size":111,"stargazers_count":4756,"open_issues_count":15,"forks_count":154,"subscribers_count":45,"default_branch":"master","last_synced_at":"2025-04-18T21:31:13.015Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/uber-go.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-02T23:39:06.000Z","updated_at":"2025-04-17T13:45:09.000Z","dependencies_parsed_at":"2023-02-19T12:31:15.020Z","dependency_job_id":"eb37bd9f-62e0-4c4e-94a8-17cc3eaafdb5","html_url":"https://github.com/uber-go/goleak","commit_stats":{"total_commits":82,"total_committers":29,"mean_commits":"2.8275862068965516","dds":0.8048780487804879,"last_synced_commit":"79b1d32d401a900ee066087464f73049354eb5c0"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber-go%2Fgoleak","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber-go%2Fgoleak/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber-go%2Fgoleak/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber-go%2Fgoleak/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uber-go","download_url":"https://codeload.github.com/uber-go/goleak/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249914635,"owners_count":21344697,"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":[],"created_at":"2024-07-31T17:00:47.380Z","updated_at":"2025-04-22T13:43:17.266Z","avatar_url":"https://github.com/uber-go.png","language":"Go","funding_links":[],"categories":["Misc","Go","开源类库","Open source library","Language-Specific Tools","Programming","开发工具\u0026框架","Golang生态圈Dev\u0026Ops工具与服务","Testing"],"sub_categories":["开发辅助包","Development Aid Package","Go","Advanced and Specialized Tools"],"readme":"# goleak [![GoDoc][doc-img]][doc] [![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov]\n\nGoroutine leak detector to help avoid Goroutine leaks.\n\n## Installation\n\nYou can use `go get` to get the latest version:\n\n`go get -u go.uber.org/goleak`\n\n`goleak` also supports semver releases.\n\nNote that go-leak only [supports][release] the two most recent minor versions of Go.\n\n## Quick Start\n\nTo verify that there are no unexpected goroutines running at the end of a test:\n\n```go\nfunc TestA(t *testing.T) {\n\tdefer goleak.VerifyNone(t)\n\n\t// test logic here.\n}\n```\n\nInstead of checking for leaks at the end of every test, `goleak` can also be run\nat the end of every test package by creating a `TestMain` function for your\npackage:\n\n```go\nfunc TestMain(m *testing.M) {\n\tgoleak.VerifyTestMain(m)\n}\n```\n\n### Note\n\nFor tests that use [t.Parallel](https://pkg.go.dev/testing#T.Parallel), `goleak` does\nnot know how to distinguish a leaky goroutine from tests that have not finished running.\n\n\n```go\nfunc TestA(t *testing.T) {\n\ttt := struct{\n\t\tname  \t string\n\t\tinput \t SomeType\n\t\texpected string\n\t}{\n\t\t// ...\n\t}\n\n\tfor _, t := range tt {\n\t\tt.Run(t.name, func(t *testing.T) {\n\t\t\tt.Parallel() // \u003c- goleak gets confused here!\n\n\t\t\t// ...\n\t\t}\n\t}\n}\n```\nFor such cases you should also defer to using `goleak.VerifyTestMain` as shown above.\n\n## Determine Source of Package Leaks\n\nWhen verifying leaks using `TestMain`, the leak test is only run once after all tests\nhave been run. This is typically enough to ensure there's no goroutines leaked from\ntests, but when there are leaks, it's hard to determine which test is causing them.\n\nYou can use the following bash script to determine the source of the failing test:\n\n```sh\n# Create a test binary which will be used to run each test individually\n$ go test -c -o tests\n\n# Run each test individually, printing \".\" for successful tests, or the test name\n# for failing tests.\n$ for test in $(go test -list . | grep -E \"^(Test|Example)\"); do ./tests -test.run \"^$test\\$\" \u0026\u003e/dev/null \u0026\u0026 echo -n \".\" || echo -e \"\\n$test failed\"; done\n```\n\nThis will only print names of failing tests which can be investigated individually. E.g.,\n\n```\n.....\nTestLeakyTest failed\n.......\n```\n\n## Stability\n\ngoleak is v1 and follows [SemVer](http://semver.org/) strictly.\n\nNo breaking changes will be made to exported APIs before 2.0.\n\n[doc-img]: https://pkg.go.dev/badge/go.uber.org/goleak.svg\n[doc]: https://pkg.go.dev/go.uber.org/goleak\n[ci-img]: https://github.com/uber-go/goleak/actions/workflows/ci.yml/badge.svg\n[ci]: https://github.com/uber-go/goleak/actions/workflows/ci.yml\n[cov-img]: https://codecov.io/gh/uber-go/goleak/branch/master/graph/badge.svg\n[cov]: https://codecov.io/gh/uber-go/goleak\n[release]: https://go.dev/doc/devel/release#policy\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuber-go%2Fgoleak","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuber-go%2Fgoleak","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuber-go%2Fgoleak/lists"}