I'm trying to detect goroutine leaks in my Go tests. However, the existing libraries I've seen all detect global leaks, not leaks of goroutines which are descendents of the test function. I want this functionality for two reasons:
- It allows me to detect leaks while still running tests in parallel (e.g. using
- It will ignore leaks which are just the fault of
initfunctions. This happens a lot in our codebase because we have, for example, a logging library imported which creates a long-running goroutine in its
In lieue of an existing leak detection library which does what I want, I'd like to build my own, but I don't want to write my own logic for parsing the output of
runtime.Stack because it's just an unstructured string. I'd like a library which can give me the actual parsed, structured, stack/goroutine information. Is there an existing library which does this? Alternatively, is there a goroutine leak detection library which does what I want?