Skip to content

Instantly share code, notes, and snippets.

@Reine0017
Created August 9, 2022 10:41
Show Gist options
  • Save Reine0017/bb4e9de30ad14ee4543b0e97f8dc7e1d to your computer and use it in GitHub Desktop.
Save Reine0017/bb4e9de30ad14ee4543b0e97f8dc7e1d to your computer and use it in GitHub Desktop.
simple channel
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