3 ms·
This brings up another question... Couldn't you just put them in the global namespace in the package? I also don't see the need for init since this is just par
by leetrout 10y ago
This brings up another question...
Couldn't you just put them in the global namespace in the package? I also don't see the need for init since this is just parsing / compiling a template one time. Maybe I'm just not a sane dev? I just put all my template and regex "must" statements as global vars in my package close to where they're used.
- randomdata 10y agoMost definitely, if you want the compiled template loaded for the life of the application, at least. The documentation for template.Must says it is intended to be used exactly like that. If you were in a regular code block, you would check the error and handle it more gracefully.