Created
March 14, 2013 17:11
-
-
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.
This file contains 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
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