4 ms·
I've recently been bit by global state that used function initializers (func init() isn't the only way to execute logic when a package is imported!). The packag
by transitorykris 9y ago
I've recently been bit by global state that used function initializers (func init() isn't the only way to execute logic when a package is imported!). The package used very reasonable defaults, but panic()'d when things didn't look right. So, forking, maintaining patches until upstream changes the behavior, painful.
- kornish 9y ago> func init() isn't the only way to execute logic when a package is imported! What are other ways to execute logic when a package is imported? init() is the only one I'm aware of.
- transitorykris 9y agopackage globals var ( X = blah() ) func blah() int { return 123 }