No description
Find a file
2024-11-23 23:11:01 +00:00
cmd/go-project-template add auth 2024-07-24 22:13:23 -07:00
config add auth 2024-07-24 22:13:23 -07:00
db add auth 2024-07-24 22:13:23 -07:00
web show logged in user in web ui 2024-07-24 23:01:44 -07:00
.gitignore Initial commit 2024-05-05 15:10:32 -07:00
go-project-template.sample.json add auth 2024-07-24 22:13:23 -07:00
go.mod chore(deps): update dependency go to v1.23.3 2024-11-23 23:11:01 +00:00
go.sum chore(deps): update golang.org/x/exp digest to 2d47ceb 2024-11-23 09:00:54 +00:00
LICENSE Initial commit 2024-05-05 15:10:32 -07:00
README.md show logged in user in web ui 2024-07-24 23:01:44 -07:00
renovate.json renovate: automerge minor + patch 2024-09-13 13:13:59 -07:00
sqlc.yaml Initial commit 2024-05-05 15:10:32 -07:00

go-project-template

This is a template for go projects. It provides a postgres database connection and a webserver.

Template Usage

This template is intended for use with gonew, but can also be manually copied and the package name updated.

After you run gonew or update the package name manually, you will also want to:

  • search for the string go-project-template and replace it with the name of your project, as that string appears in a few places other than the package name itself.
  • Rename the sample config file in the root from go-project-template.sample.json
  • You might want to put a human-readable project name in httpserver/templates/base.html, where go-project-template appears multiple times.
  • Rewrite this README

Project Usage

This project requires a postgres server. For development, it is usually easiest to create a temporary database in a container:

docker run --rm --name postgresql -e POSTGRES_PASSWORD=password -p 5432:5432 library/postgres

Then make a copy of the sample config file:

cp go-project-template.sample.json go-project-template.json

The database schema and migrations are defined in db/migrations/. Migrations are applied by goose when the program starts. Queries are written in database/queries/, which gets read by sqlc to generate much of the go code in db/. If you update a query, run sqlc generate to update the generated go files.