Created
April 13, 2022 21:19
-
-
Save eminetto/fd413efec239149471b2402e442b5ce2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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