By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
Relay is an event and log service. Applications send it structured events — one JSON object per line — and operators ask it what happened: which service is failing, which status codes are spiking, how long requests take. It is a small enough product to finish and a real enough one to expose every production problem worth teaching.
You grow Relay in three stages. First it is a CLI log analyzer that reads a JSONL file and prints an aggregate report. Then it becomes a JSON HTTP API that ingests events and serves the same aggregates. Finally you make it a production service: concurrent ingestion, storage, observability, rate limits, background jobs, security and a container image. Each stage keeps the earlier code; nothing is thrown away.
Go is distributed as a single toolchain: the compiler, the formatter, the test runner, the profiler and the module manager all live behind one go command. Install the latest release from the official download page, then confirm the version. If a module asks for a newer toolchain than you have, Go 1.21+ downloads it automatically unless you disable that behavior.
# 1. Verify the toolchain. Go 1.23 or newer is expected.
go version
# 2. Create the module every later step builds on.
mkdir relay && cd relay
go mod init relay
# 3. Create only the directories you need today; this layout grows with you.
mkdir -p cmd/relay internal/analyze testdata
# 4. The loop you will repeat hundreds of times.
go run ./cmd/relay --help
go test ./...
go vet ./...go mod init relay writes a go.mod file that declares the module path. Inside the module, first-party packages are imported by that path: relay/internal/analyze. The cmd/ directory holds executable entry points, internal/ holds packages that cannot be imported by other modules, and testdata/ holds fixture files the test runner ignores. This is a convention, but it is the convention every Go developer expects to find.
| Command | What it does | When you reach for it |
|---|---|---|
go run ./cmd/relay | Compiles and runs one program | Every edit loop |
go test ./... | Runs tests in every package | Before every commit |
go vet ./... | Flags suspicious code | Alongside tests |
gofmt -l . | Lists files that are not formatted | CI and pre-commit |
go build -o bin/relay ./cmd/relay | Produces a binary | Releases and containers |
go mod tidy | Aligns go.mod with imports | After adding or removing code |
Most languages ask you to choose between a simple service and a concurrent one. Go does not: goroutines are cheap enough that ordinary code can start them, and channels are ordinary enough that they become part of the function signature. Keep four ideas in your head for the whole path:
go f() plus a context.Context and a bounded amount of coordination beats a thread pool you did not write.Key takeaways
Relay is the single project spine: CLI analyzer, then HTTP API, then production service.
Install Go 1.23+ and verify with go version; the toolchain bundles the compiler, test runner, formatter and profiler.
go mod init relay creates the module that every later import path hangs from.
The everyday loop is go run, go test, go vet, gofmt and go build.
Read Go as values plus explicit errors plus cheap goroutines; translation from another language is where bugs enter.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.