Skip to content

Commit

Permalink
Explicitly pass context to goroutine (gopasspw#2425)
Browse files Browse the repository at this point in the history
Previously, the `ctx` when calling ctx.Done() is fetched from main
function stack, which is updated multiple times.

Signed-off-by: Tony Wang <tony@initialcommit.net>

Signed-off-by: Tony Wang <tony@initialcommit.net>
  • Loading branch information
wwwjfy authored Nov 24, 2022
1 parent 8b40aa3 commit 5981a5a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ func main() {
cancel()
}()

go func() {
go func(ctx context.Context) {
select {
case <-sigChan:
cancel()
case <-ctx.Done():
}
}()
}(ctx)

cli.ErrWriter = errorWriter{ //nolint:reassign
out: colorable.NewColorableStderr(),
Expand Down

0 comments on commit 5981a5a

Please sign in to comment.