xtools$ cat b.go
//go:build go1.25

package tools

import "sync"

func _() {
    var s Server
    s.wg.Add(1)
    go func() {
        print()
        s.wg.Done()
    }()
}

type Server struct {
    wg sync.WaitGroup
}
xtools$ go run ./gopls/internal/analysis/modernize/cmd/modernize -fix -diff  ./b.go
--- /Users/adonovan/w/xtools/b.go (old)
+++ /Users/adonovan/w/xtools/b.go (new)
@@ -6,11 +6,9 @@

 func _() {
    var s Server
-   s.wg.Add(1)
-   go func() {
+   &{s wg}.Go(func() {
-       print()
-       s.wg.Done()
+       print()
-   }()
+   })
 }

Comment From: gabyhelp

Related Issues

Related Code Changes

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)