I saved this as a snippet for vscode to get up and running quickly with something better than the defaults for handling
func main isolation. I’ve been working on modifying this a bit as I don’t really like using args, but am trying not to overcomplicate things as a new gopher.
I prefer better flag parsing rather than using args. This pattern isolates functions from the main function to make them easily testable.
The gist is to ensure that
main is where program termination happens, instead of handling this in your functions. This isolation of logic from main ensures you can more easily set up your tests since
func main() isn’t testable.