Author: @nexovec
Uses: APIs, glorious monolith applications, high performance HTTP
This is my personal HTTP server template. Since I'm responsible for making more than one project with a common structure, a template is a nice to have
BONUS: this is available as open source.
You need to have go 1.22 and docker installed. Primarily, only linux is supported. Recommended vs code extensions are: Git lens, go nightly, error lens, intellicode, templ lsp. Additionally, installation of graphviz is recommended.
TODO: move things from
air.toml
pre_cmd
into here to speed up builds
You can launch the project with docker compose up --build
.
You should run templ generate --watch
to watch for changes to template directories.
You might need to run go work sync && go work vendor
as sudo when adding new packages.
You can run sqlc generate --file configs/sqlc.yml
to generate accessor functions for new SQL commands in internal/moels/queries
you can uncomment the command in
configs/air.toml
to get "hot-reload" (but it's quite slow).
You might need to run pnpm install
to get tools to be able to build client-side css and javascript.
This specifically uses postgres for its good sqlc support, lots of available extensions and libraries, and its popularity. SQLite should be considered for simple CRUD apps.
We use basic go migrate for db migrations. We don't use ORMs, but we use sqlc to generate access methods for raw SQL queries.
We use the in-memory cache Otter for its excellent performance and simple API.
Framework of choice is go fiber, for excellent performance and simple API.
We use lodash for go to suplement what we don't have in the stdlib, this has the added benefit of being similar to javascripts equivalent.
Air is in charge of hot-reloading.