Skip to main content
Batteries-included Go template

Build Go services faster

An opinionated Go project template for scrapers, bots, and service workloads. Get TLS-fingerprinted HTTP clients, exponential backoff, bounded concurrency, PostgreSQL, and structured logging out of the box.

Clone with gonew:

gonew github.com/aarock1234/go-template@latest github.com/you/myproject

Get started in minutes

Clone the template, run setup, and start building your service

1

Install gonew

First, install the gonew tool from the Go team:
go install golang.org/x/tools/cmd/gonew@latest
2

Clone the template

Use gonew to scaffold your project. This clones the template and rewrites all import paths to your module name:
gonew github.com/aarock1234/go-template@latest github.com/you/myproject
cd myproject
3

Run the setup wizard

Configure optional features interactively. Choose which components you need:
make setup
The wizard lets you opt in or out of Docker, PostgreSQL, and individual packages. All features are pre-selected by default.
4

Configure your environment

Copy the example environment file and set your configuration:
cp .env.example .env
# Edit .env with your DATABASE_URL and other settings
5

Start building

Run your application locally:
make dev
Or with Docker:
make up
Replace pkg/template with your own domain logic and update cmd/template/main.go to wire your services together.

Explore by topic

Jump into the area you need to learn about

HTTP Client

TLS-fingerprinted HTTP clients with custom headers, cookies, and proxy support

Retry Logic

Exponential backoff with full jitter for transient-error recovery

Concurrency

Bounded-concurrency primitives for parallel processing with errgroup

State Management

File-backed JSON persistence with cross-platform locking

Database

PostgreSQL integration with pgx, sqlc queries, and transactions

Configuration

Environment variable loading with struct-tag validation

Logging

Structured logging with slog and tint for beautiful output

File Rotation

Thread-safe round-robin file rotation utilities

Utilities

Generic pointer helpers and other Go conveniences

Key features

Everything you need to build production-ready Go services

TLS Fingerprinting

Mimic real browser TLS/HTTP2 fingerprints including Chrome, Firefox, Safari, and Edge on Windows, macOS, and Android

Smart Retries

Exponential backoff with full jitter, configurable max attempts, delays, and multipliers for resilient error handling

Controlled Concurrency

Process items in parallel with bounded worker pools, automatic context cancellation, and result collection

Production PostgreSQL

Connection pooling with pgx, type-safe sqlc queries, transaction helpers, and advisory lock support

Stateful Persistence

File-backed JSON state with exclusive locking to prevent concurrent access across multiple process instances

Beautiful Logs

Structured logging with slog and tint, context injection, and colorized output for development

Ready to build your next Go service?

Clone the template with gonew and get production-ready infrastructure in minutes