This is a starter template for a Go-based API.
cmd/: Contains the main application entry point.db/: Contains database-related files, including migrations and SQL queries.migrations/: Database migration files.queries/: SQL queries forsqlc.sqlc/: Generated Go code fromsqlc.
mail/: Contains mail-related functionality..env.example: Example environment variables file.Makefile: Contains helper commands for development.docker-compose.yml.example: Example Docker Compose file.go.mod: Go module file.go.sum: Go module checksums.sqlc.yaml: Configuration forsqlc.
- Copy
.env.exampleto.envand fill in your environment variables. - Run
make vendorto install dependencies. - Run
make db/migrations/upto apply database migrations. - Run
make run/apito start the API server.
run/api: Run the API server.db/psql: Connect to the database usingpsql.db/migrations/new name=<migration_name>: Create a new database migration.db/migrations/up: Apply all up migrations.db/migrations/down: Apply all down migrations.audit: Format, vet, and test the code.vendor: Tidy, verify, and vendor Go module dependencies.sqlc: Generate Go code from SQL queries usingsqlc.