Code from https://pkg.go.dev/golang.org/x/sync/errgroup?tab=doc
var g errgroup.Group var urls = []string{ "http://www.golang.org/", "http://www.google.com/", "http://www.somestupidname.com/", } for _, url := range urls { url := url g.Go(func() error { // Fetch the URL. resp, err := http.Get(url) if err == nil { resp.Body.Close() } return err }) } if err := g.Wait(); err == nil { fmt.Println("Successfully fetched all URLs.") } Out of 3, suppose 2 Goroutines will keep running in parallel without error and while calling “http://www.google.com/”, it got an error. That will be collected at g.Wait(). My question is Does *errgroup* terminates the other 2 running Goroutines if the main keeps running? Or I need to use errgroup.WithContext(ctx) and keep listening this context if its ctx.Done() and then terminate my goroutine?? -- 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 golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CANFuhy-3Wz3q_RK4JZxH%3DT-N4k%2BEQHY5j1ZAdEEX_TicmnV4TQ%40mail.gmail.com.