Skip to content

Instantly share code, notes, and snippets.

@mmorearty
Created March 14, 2013 17:11
Show Gist options
  • Save mmorearty/5163181 to your computer and use it in GitHub Desktop.
Save mmorearty/5163181 to your computer and use it in GitHub Desktop.
Cute: in #golang, any function called init() is automatically executed, AND you can have more than one per source file.
package main
func init() {
println("first")
}
func init() {
println("second")
}
func main() {
// even though main() is empty, this program will print
// "first" and then "second"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment