When creating a piece of software in Golang you are not obligated to separate your code into logical packages. You can go ahead and have everything in a single package called main and it will work fine. Until you start to write tests and the most simple unit test will take seconds to complete when running go test
. Why is this? Because go test
compiles everything that needs to be compiled in order to run the tests. So if you have defined only one package then EVERYTHING is going to be compiled. Even third party libraries...
So creating logical packages benefits your program's structure and maintainability, but also speeds up your test times, or gives you back the time lost when testing with one package name. Depends on the angle you look at it...