Apply go fix -waitgroup ./...

This commit is contained in:
Michael Eischer
2026-07-22 22:27:21 +02:00
parent 14e523a1d9
commit f215365af9
4 changed files with 10 additions and 20 deletions
+2 -4
View File
@@ -342,13 +342,11 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts global.Options, args
var brokenSnapshots []string
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
bar := printer.NewCounter("snapshots")
defer bar.Done()
chkr.Structure(ctx, bar, errChan)
}()
})
for err := range errChan {
errorsFound = true
+4 -8
View File
@@ -56,16 +56,14 @@ func run(errorLog func(string, ...any), command string, args ...string) (*StdioC
waitCh := make(chan struct{})
// start goroutine to add a prefix to all messages printed by to stderr by rclone
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
defer close(waitCh)
sc := bufio.NewScanner(p)
for sc.Scan() {
errorLog("rclone: %v\n", sc.Text())
}
debug.Log("command has exited, closing waitCh")
}()
})
r, stdin, err := os.Pipe()
if err != nil {
@@ -207,9 +205,7 @@ func newBackend(ctx context.Context, cfg Config, lim limiter.Limiter, errorLog f
ctx, cancel := context.WithCancel(ctx)
defer cancel()
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
<-waitCh
cancel()
@@ -219,7 +215,7 @@ func newBackend(ctx context.Context, cfg Config, lim limiter.Limiter, errorLog f
be.waitResult = err
// close our side of the pipes to rclone, ignore errors
_ = stdioConn.CloseAll()
}()
})
// send an HTTP request to the base URL, see if the server is there
client := http.Client{
+2 -4
View File
@@ -225,12 +225,10 @@ func TestFreeze(t *testing.T) {
// Start Save call that should block
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
h := backend.Handle{Type: backend.PackFile, Name: "foobar"}
test.OK(t, be.Save(context.TODO(), h, nil))
}()
})
// check
time.Sleep(1 * time.Millisecond)
+2 -4
View File
@@ -80,11 +80,9 @@ func Setup(stdin io.ReadCloser, stdout, stderr io.Writer, quiet bool) (ui.Termin
cancelCtx, cancel := context.WithCancel(context.Background())
term := new(stdin, stdout, stderr, quiet)
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
term.Run(cancelCtx)
}()
})
return term, func() {
if term.outputWriter != nil {