Skip to content

Instantly share code, notes, and snippets.

@vderyagin
Created November 19, 2012 08:22
Show Gist options
  • Save vderyagin/4109558 to your computer and use it in GitHub Desktop.
Save vderyagin/4109558 to your computer and use it in GitHub Desktop.
concurrent "Hello World" in Golang
package main
import "fmt"
/*
concurrent hello world
*/
func main() {
sayHello := make(chan bool)
sayWorld := make(chan bool)
finished := make(chan bool)
go func() {
<-sayWorld
fmt.Println("World")
finished <- true
}()
go func() {
<-sayHello
fmt.Print("Hello ")
sayWorld <- true
}()
sayHello <- true // kick off
<-finished // wait until done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment