Created
August 9, 2022 10:41
-
-
Save Reine0017/bb4e9de30ad14ee4543b0e97f8dc7e1d to your computer and use it in GitHub Desktop.
simple channel
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
package main | |
import ( | |
"fmt" | |
) | |
func NameFunc(nameChannel chan string, name string) { | |
finalName := "Name: " + name | |
nameChannel <- finalName | |
} | |
func main() { | |
nameChannel := make(chan string) | |
go NameFunc(nameChannel, "Reine") | |
value := <-nameChannel //blocking call | |
fmt.Println("value", value) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment