Created
November 22, 2023 12:11
-
-
Save yumed15/e6f9818ca581cc17820239cdda43dd33 to your computer and use it in GitHub Desktop.
This file contains 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
// BAD | |
var wg sync.WaitGroup | |
for _, salutation := range []string{"hello", "greetings", "good day"} { | |
wg.Add(1) | |
go func() { | |
defer wg.Done() | |
fmt.Println(salutation) | |
}() | |
} | |
wg.Wait() | |
// good day | |
// good day | |
// good day |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment