Skip to content

Instantly share code, notes, and snippets.

@anxiousmodernman
Last active August 29, 2015 14:09
Show Gist options
  • Save anxiousmodernman/d3fe6a9c58135c6fabce to your computer and use it in GitHub Desktop.
Save anxiousmodernman/d3fe6a9c58135c6fabce to your computer and use it in GitHub Desktop.
Go lookin' all JavaScript
func myMethod (myThing myType) (retVal string, val int) {
val = 0
retVal = "Farhan"
}
func main() {
if _, err := myType.myMethod(); !err {
// do stuff
}
done := make(chan bool) // init a channel of bool
// anonymous function
go func() {
myType.MyMethodDoingStuff()
done <- true // when method's done, put true on the channel
}() // yo, goroutine! execute yo'self!
somethingElse.DoSomethingElse()
val bool;
val <- done // channel will block until a bool is put on it
// so program won't exit until goroutine is done
}
@anxiousmodernman
Copy link
Author

Or you could assign a value for what pops out of done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment