Thank you both for the replies.
Hi Tamas, I am wondering about:
go func() {
<-sigCh
cancel()
}
If the program exits normally, presumably sigCh channel will not get
notified, and this goroutine will continue to run. How do we ensure that it
quits on normal program exit?
Regards,
Sundar
On Wednesday, January 24, 2018 at 6:08:25 AM UTC-8, Tamás Gulácsi wrote:
>
> func main() {
> if err := Main(); err != nil {
> log.Fatal(err)
> }
> }
>
> func Main() error {
> ctx, cancel := cintext.WithCanvel(context.Background())
> defer cancel()
> sigCh := make(chan signal.Signal, 1)
> go func() {
> <-sigCh
> cancel()
> }
> signal.Notify(sigCh, signal.Interrupt)
>
> ...
>
> return nil
> }
>
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.