A Go web service boilerplate with Gin, Cobra CLI, and GORM.
- Go 1.24+
- Node.js 20+
- Air (for hot reload during development)
go install github.com/air-verse/air@latest
cd web && npm install && cd ..
make devOpen http://localhost:3000 - both frontend and backend hot reload on code changes.
make devRuns both backend (Air) and frontend (Next.js) with hot reload. Frontend at http://localhost:3000 proxies API calls to backend at http://localhost:8080.
aircd web && npm run devmake build.
├── cmd/ # CLI commands (Cobra)
├── internal/ # Application internals
│ ├── conf/ # Configuration
│ ├── handler/ # HTTP handlers
│ ├── middleware/ # Gin middleware
│ ├── model/ # Database models
│ ├── op/ # Business operations
│ ├── router/ # Route definitions
│ └── utils/ # Utilities
├── scripts/ # Build and Docker scripts
├── static/ # Static files
├── web/ # Next.js frontend (App Router)
└── main.go # Entry point
Configuration is loaded from data/config.json. If not found, a default config will be created automatically.
Environment variables can override config values with prefix GOBOILERPLATE_ (e.g., GOBOILERPLATE_SERVER_PORT=3000).
To create a new project from this boilerplate:
./scripts/migrate.sh my-new-project github.com/myorg/my-new-projectThis will rename all references from go-boilerplate/goboilerplate to your new project name.