Skip to content

Instantly share code, notes, and snippets.

@gocs

gocs/goroutine.go

Created Apr 8, 2019
Embed
What would you like to do?
goroutine with channels life cycle
package main
import "fmt"
func do_stuff(done chan bool) {
fmt.Println("2")
done <- true
fmt.Println("3")
}
func main() {
done := make(chan bool)
go do_stuff(done)
fmt.Println("1")
<-done // forces `do_stuff` to do job
fmt.Println("4")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.