uber-go / goleak

Goroutine leak detector
MIT License
4.48k stars 148 forks source link

Add DefaultIgnoreFunctionSet #127

Open sywhang opened 1 month ago

sywhang commented 1 month ago

This exposes a variable DefaultIgnoreFunctionSet, which can be used to set a default list of functions to ignore for goleak.

Note that this mechanism is intended for library or tool authors who cannot directly call Ignore* Options to set up how their consumers are running the tests. They should be able to use linkname to set this variable to some well-known list of goroutines that leak if they really want to exempt their goroutines from getting continously flagged by goleak.

Fixes #119.

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.17%. Comparing base (898a938) to head (974cb98).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #127 +/- ## ========================================== + Coverage 99.14% 99.17% +0.02% ========================================== Files 5 5 Lines 234 242 +8 ========================================== + Hits 232 240 +8 Misses 1 1 Partials 1 1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

fmeum commented 1 month ago

I would still consider this useful, but since https://github.com/bazelbuild/rules_go/commit/0f1e0ae83d2a6f0746b9c083880b5c2239e3256f, rules_go doesn't need it anymore. Cc @linzhp

abhinav commented 1 month ago

They should be able to use linkname to set this variable to some well-known list of goroutines that leak if they really want to exempt their goroutines from getting continously flagged by goleak.

Will that still be possible following https://github.com/golang/go/issues/67401?

sywhang commented 1 month ago

since rules_go no longer needs this, I think it's better to repurpose this feature specifically for library authors and expose a top-level function to append to ignorelist. Will work on that change and fix this PR