Created
April 17, 2018 02:18
-
-
Save YasushiKobayashi/ea6bdeb41d4968e73b363c48a869be27 to your computer and use it in GitHub Desktop.
errgroup
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" | |
"golang.org/x/sync/errgroup" | |
) | |
func main() { | |
fmt.Println("vim-go") | |
eg := errgroup.Group{} | |
for i := 0; i < 10; i++ { | |
i := i | |
eg.Go(func() error { | |
fmt.Println(i) | |
return fmt.Errorf("err") | |
fmt.Println(i) | |
if i == 9 { | |
return fmt.Errorf("err") | |
} | |
return nil | |
}) | |
} | |
fmt.Println("wait") | |
if err := eg.Wait(); err != nil { | |
fmt.Println(err) | |
} | |
fmt.Println("end") | |
} |
Author
YasushiKobayashi
commented
Apr 17, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment