Skip to content

Instantly share code, notes, and snippets.

@eminetto
Created April 13, 2022 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eminetto/fd413efec239149471b2402e442b5ce2 to your computer and use it in GitHub Desktop.
Save eminetto/fd413efec239149471b2402e442b5ce2 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
)
func main() {
errs := make(chan error, 3)
go upload(errs)
go upload(errs)
go upload(errs)
for i:=0; i<3;i++ {
err := <- errs
if err != nil {
fmt.Println(err)
}
}
close(errs)
}
func upload(cerr chan<- error) {
fmt.Println("entrou")
time.Sleep(10)
cerr <- fmt.Errorf("erro")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment