Skip to content

rule to propose using wg.Go #1481

@chavacava

Description

@chavacava

Go 1.25 adds the method func (wg *WaitGroup) Go(f func())
This method allows rewriting code like

wg.Add(1)
go func() {
	defer wg.Done()
	doSomething()
}()

into

wg.Go(func() {
	doSomething()
})

revive could spot code fragments where the new method can be used to replace the more verbose (and sometimes fragile) legacy idiom.

rule name: use-wg-go (or use-waitgroup-go)

A prototype implementation of the rule can be found at the sandbox branch
(the rulename in the branch is deleteme)
You can run the rule with revive -config deleteme.toml ./...

Metadata

Metadata

Assignees

No one assigned

    Labels

    rule proposalIssue proposing a new rule

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions