Skip to content

Instantly share code, notes, and snippets.

@inizovtsev
Created April 16, 2017 22:13
Show Gist options
  • Save inizovtsev/677269983b0a4e5726ee2ec893f60743 to your computer and use it in GitHub Desktop.
Save inizovtsev/677269983b0a4e5726ee2ec893f60743 to your computer and use it in GitHub Desktop.
golang initialization order
package main
var answer = say()
func main() {
println("And that was the question?")
}
func say() int {
println("That is the answer?")
return 42
}
func init() {
println("The answer is", answer)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment