brandur.org

A new version of goleak (1.3.0) includes IgnoreAnyFunction function which allows a specific function to be ignored at any level of a goroutine’s stack. Previously, only a function at the top layer could be ignored, which forced us to ignore extremely generic functions like time.Sleep.

For example, this ignore, which was ignoring an internal function deep in the standard library (internal/poll.runtime_pollWait):

goleak.IgnoreTopFunction("internal/poll.runtime_pollWait")

Becomes this, which property ignores the specific offending goroutine in Pgx:

goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgconn/internal/bgreader.(*BGReader).bgRead")