2026-05-19 04:09:33 -04:00
2026-05-19 04:09:33 -04:00
2026-05-19 04:09:33 -04:00
2026-05-19 04:09:33 -04:00
2026-05-19 04:09:33 -04:00
2026-05-18 21:20:44 -04:00
2026-05-19 03:37:56 -04:00
2026-05-19 03:37:56 -04:00
2026-05-19 04:09:33 -04:00

Go HTTP server

A simple Go HTTP server boilerplate with Echo, structured logging, graceful shutdown, and Docker support.

Prerequisites

  • Go 1.25+
  • Docker and Docker Compose (for containerized runs)

Configuration

Copy the example environment file and adjust values if needed:

cp .env.dist .env

The application reads configuration from process environment variables (via envconfig). Docker Compose loads .env automatically. For a local go run, export variables or source the file:

set -a && source .env && set +a
Variable Default Description
LOG_LEVEL info Zap log level (debug, info, warn, error)
API_PORT 3000 HTTP listen port
API_READ_TIMEOUT 7 Server read timeout (seconds)
API_WRITE_TIMEOUT 5 Server write timeout (seconds)
API_IDLE_TIMEOUT 5 Server idle timeout (seconds)
API_TIMEOUT 5 Reserved for future use

Inside Docker, the process always listens on port 3000; API_PORT in .env controls the host port mapping.

make setup-docker   # copy .env, download modules, build and start containers

Or step by step:

make setup-local    # copy .env (if missing) and go mod download
make run            # docker compose up --build

Verify:

curl http://localhost:3000/health

Stop:

make down

Run locally (without Docker)

make setup-local
make run-local

Build binary

make build
./bin/server

Make targets

make help

Common targets: run, run-local, down, setup-local, setup-docker, build, tests, lint.

Description
No description provided
Readme 8.1 MiB
Languages
Go 85.7%
Makefile 9.9%
Dockerfile 4.4%