Prerequisites
Before you begin, make sure you have:- Go 1.26+ - Download from go.dev
- Docker (optional) - Get Docker
The template uses generics and features from Go 1.26. Earlier versions are not supported.
Installation
Install gonew
gonew is a Go tool that clones templates and automatically rewrites import paths to your module name.Scaffold your project
Replace This command:
github.com/you/myproject with your actual module path:- Clones the template repository
- Rewrites all import paths from
github.com/aarock1234/go-templatetogithub.com/you/myproject - Creates a new directory named
myproject
Run the setup wizard
The setup wizard lets you choose which features to keep and which to remove:You’ll be prompted to configure:
- Docker support (Dockerfile + compose)
- PostgreSQL support (database + migrations)
- Optional packages (HTTP client, worker pool, retry, etc.)
Configure environment
Copy the example environment file:Edit
.env to configure your application:.env
What You Get
After running the setup wizard, your project will have:Example Output
The template includes a working example that demonstrates the HTTP client:pkg/template/example.go makes a request to a TLS fingerprinting test endpoint:
Next Steps
Now that you have a working project:Setup Guide
Learn more about the setup wizard and customization options
Development
Explore available make commands and development workflow
Common Commands
Here are the most frequently used commands:| Command | Description |
|---|---|
make dev | Run the application locally |
make build | Compile binary to bin/template |
make test | Run tests with race detector |
make lint | Static analysis with go vet |
make format | Format code with go fmt |
Troubleshooting
gonew: command not found
gonew: command not found
Make sure Then reload your shell or run
$GOPATH/bin is in your PATH. Add this to your shell profile:source ~/.bashrc (or ~/.zshrc).Database connection failed
Database connection failed
If you’re using the Docker postgres:If using an external database, verify your
DATABASE_URL in .env is correct.Import errors after setup
Import errors after setup
Run The setup wizard runs this automatically, but you may need it if you add new imports.
go mod tidy to clean up module dependencies: