A simple opinionated Go web app template
Find a file
2026-08-18 08:04:46 +03:00
.githooks cicd: Add a precommit hook to check formatting with gofmt. Add guide on how to add precommit hooks in the README 2026-08-18 00:45:47 +03:00
cmd feat: Remove godotenv. Replace it with our own function that reads .env on start 2026-08-18 00:30:20 +03:00
internal feat: Pass user to index template 2026-08-18 08:04:46 +03:00
migrations feat: Add Sliding expiration for user_sessions 2026-08-17 23:47:11 +03:00
scripts Initial commit 2026-08-15 23:57:52 +03:00
ui feat: Pass user to index template 2026-08-18 08:04:46 +03:00
.air.toml Initial commit 2026-08-15 23:57:52 +03:00
.dockerignore build: Add Dockerfile and dockerignore 2026-08-18 00:40:23 +03:00
.env.example Initial commit 2026-08-15 23:57:52 +03:00
.gitignore Initial commit 2026-08-15 23:57:52 +03:00
Dockerfile build: Add Dockerfile and dockerignore 2026-08-18 00:40:23 +03:00
go.mod feat: Remove godotenv. Replace it with our own function that reads .env on start 2026-08-18 00:30:20 +03:00
go.sum feat: Remove godotenv. Replace it with our own function that reads .env on start 2026-08-18 00:30:20 +03:00
Makefile build: Add Makefile, update README 2026-08-18 08:04:20 +03:00
README.md build: Add Makefile, update README 2026-08-18 08:04:20 +03:00
sqlc.yaml Initial commit 2026-08-15 23:57:52 +03:00
todo.txt feat: Add Sliding expiration for user_sessions 2026-08-17 23:47:11 +03:00

Go Backend Template

A simple opinionated Go web app template.

The intention for this project is to work as a template, where the developer should be able to concentrate right away on the business problem and not the usual dev environment and auth wiring. The focus is intentionally on mainly functionality, so the UI is bare-bones.

Features

  • Session-based authentication with a sliding expiration
  • Argon2 password hashing
  • PostgreSQL database
  • CORS support
  • Request logging middleware
  • Native Go HTTP server (no external frameworks)
  • HTMX for interactivity

Requirements

  • Go 1.24+

  • PostgreSQL

  • goose for migrations

  • sqlc for generating type-safe queries from SQL

  • air for live reload (optional)

    go install github.com/pressly/goose/v3/cmd/goose@latest
    go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
    go install github.com/air-verse/air@latest
    

Setup

  1. Run setup (copies .env.example to .env, runs go mod tidy, enables the repo's git hooks which reject commits with unformatted Go files):

    make setup
    
  2. Update .env with your database credentials (both the DB_* and GOOSE_* values).

  3. Run database migrations:

    make migrate-up
    
  4. Run the server:

    make dev   # live reload, or:
    make run
    

Migrations

make migrate-up / make migrate-down / make migrate-status load .env and pass through to goose. Create a new migration with:

make migrate-create name=add_widgets

SQLC

Query codegen is configured in sqlc.yaml (engine postgresql, schema read from migrations/). Add .sql files under internal/database/queries/ and run make generate to emit typed accessors into internal/database/sqlc/.

Database Schema

  • user_auth - User accounts with Argon2 password hashes
  • user_session - User sessions with SHA-256 hashed token secrets