Last active
August 29, 2015 14:09
-
-
Save anxiousmodernman/d3fe6a9c58135c6fabce to your computer and use it in GitHub Desktop.
Go lookin' all JavaScript
This file contains hidden or 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
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Or you could assign a value for what pops out of
done