Skip to content

Go:Modernize

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

요약하면 Go:sync#WaitGroup.Go를 사용하라는 의미. 다음과 같은 코드가 있을 때:

    if pm.fileBackupDays > 0 {
        pm.waitGroup.Add(1)
        go func() {
            defer pm.waitGroup.Done()
            pm.FileCleaner.periodicFileCleanup(pm.context.Done())
        }()
    }

다음과 같이 변경하자:

    if pm.fileBackupDays > 0 {
        pm.waitGroup.Go(func() {
            pm.FileCleaner.periodicFileCleanup(pm.context.Done())
        })
    }

See also

Favorite site