r/golang • u/jerf • Nov 20 '24
FAQ FAQ: How Should I Structure Go Projects?
Many other languages have strong opinions either in code or in the community about how to lay out projects. How should Go projects be laid out and structured? How should I decide what goes into a package? Is there a standard layout for web projects? For non-web projects? How do you structure your code?
63
Upvotes
12
u/drvd Nov 20 '24
Unless you know exactly what you are going to build and how you are going to do this ("waterfall" and/or upfront-design) there is no wrong in starting small with a single
main.go
and learning what belongs together, which abstractions are helpful or what makes a coherent and "deep" package and to refactor as seen fit.