refactor(leak): replace init() guard with lazy sync.Once check#82
refactor(leak): replace init() guard with lazy sync.Once check#82
Conversation
The compatibility guard for pprof goroutine profile label format now runs lazily via sync.Once on the first call to Leaked(), instead of eagerly in init(). This avoids overhead and potential panics for programs that import the assertions package but never use NoGoRoutineLeak. Signed-off-by: GitHub Copilot <[email protected]> Co-authored-by: fredbi <[email protected]>
fredbi
left a comment
There was a problem hiding this comment.
Please fix linting issues
Error: /home/runner/work/testify/testify/internal/leak/leak.go:28:5: compatOnce is a global variable (gochecknoglobals)
var compatOnce sync.Once
^
Error: /home/runner/work/testify/testify/internal/leak/leak.go:47:4: waitgroup: Goroutine creation can be simplified using WaitGroup.Go (modernize)
go func() {
^
2 issues:
- gochecknoglobals: 1
- modernize: 1
- Add //nolint:gochecknoglobals annotation with justification on compatOnce - Replace wg.Add(1)/go func()/defer wg.Done() with wg.Go() (Go 1.25) Signed-off-by: GitHub Copilot <[email protected]> Co-authored-by: fredbi <[email protected]>
Fixed in f0a5970: added |
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (59.25%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #82 +/- ##
==========================================
+ Coverage 91.18% 91.24% +0.05%
==========================================
Files 91 91
Lines 11929 11929
==========================================
+ Hits 10878 10885 +7
+ Misses 835 830 -5
+ Partials 216 214 -2 ☔ View full report in Codecov by Sentry. |
init()withensureCompatible()guarded bysync.Once, called at the top ofLeaked()gochecknoinitslint suppressiongochecknoglobalslint: add//nolintannotation with justification oncompatOncemodernizelint: usewg.Go()instead ofwg.Add(1); go func()...📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.