https://github.com/joshi4/goroutine-inspector
easy to use package for testing go routine events
https://github.com/joshi4/goroutine-inspector
golang leaky-goroutine testing
Last synced: 10 months ago
JSON representation
easy to use package for testing go routine events
- Host: GitHub
- URL: https://github.com/joshi4/goroutine-inspector
- Owner: joshi4
- License: mit
- Created: 2017-12-13T04:10:56.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-31T07:06:18.000Z (over 8 years ago)
- Last Synced: 2025-08-24T17:47:04.008Z (10 months ago)
- Topics: golang, leaky-goroutine, testing
- Language: Go
- Size: 446 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Goroutine Inspector
## Motivation
Often I found myself in the following scenario: TestXXX byitself passes but running the whole test suite results in an error.
Usually, this means theres an unexpected mutation of global state caused by the interaction between two or more test cases.
A large fraction of the time the root cause of the problem is that there is a go routine leak somewhere.
From here we have to audit the code carefully or resort to adding debug print statements to figure out which goroutine has escaped.
Goroutine Inspector makes the task of finding leaked goroutines as easy as adding a couple of lines of code to the test suite. It also ensures that any go routines that leak are caught immediately, thus ensuring a clean and safe codebase.
## Example Usage
## Caveat
Under the hood goroutine-inspector relies on an execution trace as its source of truth, if due to the vagaries of the scheduler a goroutine doesn't emit the `GoroutineStop` event it will be considered as having leaked, so some false positives are possible.
## Contribution
PR's and bug reports are welcome :)