mirror of
https://github.com/restic/restic.git
synced 2026-08-06 05:33:17 +00:00
Apply go fix -waitgroup ./...
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user