Created
March 8, 2020 06:32
-
-
Save dumindu/57c84a63415a3e1ea02b4e91605060e7 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" | |
"sync" | |
) | |
func main() { | |
wg := sync.WaitGroup{} | |
wg.Add(1) | |
greet := "Hello world!" // We have moved the "Hello world!" string to a variable, greet | |
go func(){ | |
fmt.Println(greet) | |
wg.Done() | |
}() | |
greet = "こんにちは世界!" // We are changing the value of greet, before wg.Wait() | |
wg.Wait() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment