▷ ࿈ଓͰγάφϧ͕དྷͯେৎ • golang.org/x/sync/errgroup Ὂ HPSPVUJOFͷཧ͕͍͢͠Α͏ʹ !8 eg, ctx := errgroup.WithContext(context.Background()) srvCtx, srvCancel := context.WithCancel(ctx) sigCh := make(chan os.Signal) sigStopCh := make(chan struct{}) signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM) eg.Go(func() error { defer close(sigCh) for { select { case <-sigStopCh: log.Println("finish signal watching") return nil case sig := <-sigCh: log.Printf("received signal %+v\n", sig) srvCancel() } } })