aboutsummaryrefslogtreecommitdiff
path: root/src/encoding
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo@golang.org>2025-11-18 17:19:04 +0100
committerGopher Robot <gobot@golang.org>2025-11-20 13:01:32 -0800
commitc1b7112af8331d37e33be521d2d8baa552945971 (patch)
treeb047983fbb754b936b728911739bed39efde264b /src/encoding
parentca37d24e0b9369b8086959df5bc230b38bf98636 (diff)
downloadgo-c1b7112af8331d37e33be521d2d8baa552945971.tar.xz
os/signal: make NotifyContext cancel the context with a cause
This is especially useful when combined with the nesting semantics of context.Cause, and with errgroup's use of CancelCauseFunc. For example, with the following code ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt) defer stop() serveGroup, ctx := errgroup.WithContext(ctx) calling context.Cause(ctx) after serveGroup.Wait() will return either "interrupt signal received" (if that happens first) or the error from serveGroup. Change-Id: Ie181f5f84269f6e39defdad2d5fd8ead6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/721700 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Sean Liao <sean@liao.dev> Auto-Submit: Filippo Valsorda <filippo@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Commit-Queue: Junyang Shao <shaojunyang@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com>
Diffstat (limited to 'src/encoding')
0 files changed, 0 insertions, 0 deletions