Go:Modernize
lastmod 2025-11-27created 2025-11-277 edits
Package modernize providers the modernizer analyzer.
Troubleshooting
Goroutine creation can be simplified using WaitGroup.Go
Goroutine creation can be simplified using WaitGroup.Go (modernize waitgroup)
──────────────────────────────────────────────────────────────────────────────
https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize#waitgroup
In short, it means to use Go:sync#WaitGroup.Go. Given code like the following:
if pm.fileBackupDays > 0 {
pm.waitGroup.Add(1)
go func() {
defer pm.waitGroup.Done()
pm.FileCleaner.periodicFileCleanup(pm.context.Done())
}()
}
Change it as follows:
if pm.fileBackupDays > 0 {
pm.waitGroup.Go(func() {
pm.FileCleaner.periodicFileCleanup(pm.context.Done())
})
}
See also
Favorite site
Pages that link here