2025 Update: Since I wrote this article lots have changed both in how I structure things but also the libraries available (like sqlc, templ) in the ecosystem. I still this has some value for newcomers as it discusses some code architectural concepts that are healthy to know.
If you want to see how I structure apps in 2025 checkout my rails-like framework Andurel. This comes with complete scaffolding, database migrations, background jobs, emails, options for authentication and dockerization, all in one cli.
This is the repository for my article on how to structure Golang applications. It can be found here.
The purpose is to show newcomers to Go how structure their applications.
If you want a comprehensive course on building fullstack web apps with go, check Golang Blog Course.
You don't need much the run this application. It has the following installed on your computer:
- Golang 1.15+
- PostgreSQL
Clone the repository and change the connectionString variable on line 26 in main.go to the following: "postgres://postgres:postgres@localhost/NAME-OF-YOUR-DATABASE-HERE?sslmode=disable"
After that, just run go run cmd/server/main.go from your terminal
MIT