Get your Go API up and running in 5 minutes!
- Go 1.25+ installed
- PostgreSQL 18+ (recommended) or use Docker
# Copy starter to your new project
cp -r starter my-go-api
cd my-go-api
# Initialize Go module (update with your module path)
go mod init github.com/yourusername/my-go-api
# Update all import paths in the codebase
# Replace "github.com/yourusername/go-chi-postgres-starter" with your module pathgo mod tidy# Copy example env file
cp .env.example .env
# Edit .env and set:
# - DATABASE_URL (your PostgreSQL connection string)
# - JWT_SECRET (generate with: openssl rand -base64 32)# Create database
createdb go_api_starter
# Install migration tool
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
# Run migrations
export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/go_api_starter?sslmode=disable"
make migrate-upmake run# Health check
curl http://localhost:8080/api/health
# Register a user
curl -X POST http://localhost:8080/api/auth/register \
-H "Content-Type: application/json" \
-d '{"email":"user@example.com","password":"password123","full_name":"John Doe"}'
# Login
curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"user@example.com","password":"password123"}'
# Use the token from login response
curl http://localhost:8080/api/users \
-H "Authorization: Bearer YOUR_TOKEN_HERE"Open http://localhost:8080/swagger/index.html in your browser.
Note: For local development, using PostgreSQL 18 directly is recommended. Docker is available as an alternative.
# Start everything with Docker
docker compose up -d --build
# Run migrations (first time)
docker compose exec api sh -c "migrate -path migrations -database \$DATABASE_URL up"Note: Docker PostgreSQL runs on port 5434 to avoid conflict with local PostgreSQL 18.
That's it! Your API is running. 🚀
- Read Architecture to understand the codebase
- Read Setup Guide for detailed setup instructions
- Check Contributing for development guidelines