Finally, there is an official document with recommended ways to structure your Go project.
To be honest, it's really minimal and liberal but that is definitely better than what is by an unfortunate name collision considered the official Go layout now.
Minimal and liberal is a good thing, it resonates with the greater Go mindset imo; that said, if I were to add anything, it's maybe link people to architecture ideas like Clean Architecture, which is often recommended in the community to structure larger projects.
I'm so glad to finally see this! Thanks for posting it. In the absence of this, the name-squatting package you reference has exploited the confusion for the author's benefit, while providing sup-optimal advice to Go newbies.
Compare and contrast this with the Go Standards project-layout repo example[1] - which ironically is not a standard at all.
Personally I prefer a bit more rigidity in how the project is structured (/pkg/, /pkg/internal/, /cmd/) since it is more opinionated and requires less thinking. Typically my repos won't just have a Go backend but also a frontend too, and supporting assets, as well as documentation (designs, decisions, etc.)
I knew it reminded me of something! Eli Bendersky's post https://eli.thegreenplace.net/2019/simple-go-project-layout-... now starts with "Update (2023-09-19): We've now published similar guidelines as part of Go's official documentation. This blog post will remain up-to-date." I've learned a lot about Go from this website.
- What should you use for the module-path argument to `go mod init` if you don't ever intend to share the repo or you don't yet know where you will be sharing it?
To be honest, it's really minimal and liberal but that is definitely better than what is by an unfortunate name collision considered the official Go layout now.
Personally I prefer a bit more rigidity in how the project is structured (/pkg/, /pkg/internal/, /cmd/) since it is more opinionated and requires less thinking. Typically my repos won't just have a Go backend but also a frontend too, and supporting assets, as well as documentation (designs, decisions, etc.)
[1] https://github.com/golang-standards/project-layout
- When are go multi-module workspaces best used?
- What should you use for the module-path argument to `go mod init` if you don't ever intend to share the repo or you don't yet know where you will be sharing it?
2. Anything is fine: just a name ("myproject"), a fake URL, a real URL. Whatever works for you.
This may seem overly simplistic and I'm not trying to be dismissive, but that's really what it comes down to. Sometimes things really are just simple.
I don't understand the desire to "standardize" and "document" everything to the microscopic detail.
- How to handle binary modules?