{"id":13610129,"url":"https://github.com/fortytw2/leaktest","last_synced_at":"2026-01-26T11:50:58.570Z","repository":{"id":43909380,"uuid":"57139093","full_name":"fortytw2/leaktest","owner":"fortytw2","description":"Goroutine Leak Detector","archived":false,"fork":false,"pushed_at":"2020-10-15T17:02:31.000Z","size":41,"stargazers_count":1042,"open_issues_count":5,"forks_count":49,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-11T10:05:36.191Z","etag":null,"topics":["go","goroutine","leak-detection","test-helper"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fortytw2.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":"2016-04-26T15:19:27.000Z","updated_at":"2025-03-14T20:18:31.000Z","dependencies_parsed_at":"2022-08-12T10:51:48.249Z","dependency_job_id":null,"html_url":"https://github.com/fortytw2/leaktest","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortytw2%2Fleaktest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortytw2%2Fleaktest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortytw2%2Fleaktest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortytw2%2Fleaktest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fortytw2","download_url":"https://codeload.github.com/fortytw2/leaktest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248641373,"owners_count":21138194,"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":["go","goroutine","leak-detection","test-helper"],"created_at":"2024-08-01T19:01:41.516Z","updated_at":"2026-01-26T11:50:53.546Z","avatar_url":"https://github.com/fortytw2.png","language":"Go","funding_links":[],"categories":["Go","Repositories"],"sub_categories":[],"readme":"## Leaktest [![Build Status](https://travis-ci.org/fortytw2/leaktest.svg?branch=master)](https://travis-ci.org/fortytw2/leaktest) [![codecov](https://codecov.io/gh/fortytw2/leaktest/branch/master/graph/badge.svg)](https://codecov.io/gh/fortytw2/leaktest) [![Sourcegraph](https://sourcegraph.com/github.com/fortytw2/leaktest/-/badge.svg)](https://sourcegraph.com/github.com/fortytw2/leaktest?badge) [![Documentation](https://godoc.org/github.com/fortytw2/gpt?status.svg)](http://godoc.org/github.com/fortytw2/leaktest)\n\nRefactored, tested variant of the goroutine leak detector found in both\n`net/http` tests and the `cockroachdb` source tree.\n\nTakes a snapshot of running goroutines at the start of a test, and at the end -\ncompares the two and _voila_. Ignores runtime/sys goroutines. Doesn't play nice\nwith `t.Parallel()` right now, but there are plans to do so.\n\n### Installation\n\nGo 1.7+\n\n```\ngo get -u github.com/fortytw2/leaktest\n```\n\nGo 1.5/1.6 need to use the tag `v1.0.0`, as newer versions depend on\n`context.Context`.\n\n### Example\n\nThese tests fail, because they leak a goroutine\n\n```go\n// Default \"Check\" will poll for 5 seconds to check that all\n// goroutines are cleaned up\nfunc TestPool(t *testing.T) {\n    defer leaktest.Check(t)()\n\n    go func() {\n        for {\n            time.Sleep(time.Second)\n        }\n    }()\n}\n\n// Helper function to timeout after X duration\nfunc TestPoolTimeout(t *testing.T) {\n    defer leaktest.CheckTimeout(t, time.Second)()\n\n    go func() {\n        for {\n            time.Sleep(time.Second)\n        }\n    }()\n}\n\n// Use Go 1.7+ context.Context for cancellation\nfunc TestPoolContext(t *testing.T) {\n    ctx, cancel := context.WithTimeout(context.Background(), time.Second)\n    defer cancel()\n    defer leaktest.CheckContext(ctx, t)()\n\n    go func() {\n        for {\n            time.Sleep(time.Second)\n        }\n    }()\n}\n```\n\n## LICENSE\n\nSame BSD-style as Go, see LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffortytw2%2Fleaktest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffortytw2%2Fleaktest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffortytw2%2Fleaktest/lists"}