← built

url-shortener-go

A small URL shortener in Go.

kind
learning go
year
2026

§01 context

I write TypeScript most days. I wanted a Go project small enough to actually finish, so I could see how Go people structure a service.

No framework and no ORM. The standard library for HTTP, pgx for Postgres, migrations as plain SQL files, and a separate binary to run them.

§02 shape

How it works

cmd/
 ├─ api/          the HTTP server
 └─ migration/    runs SQL migrations
internal/
 ├─ config/       env → typed config
 ├─ db/           pgx pool
 ├─ handlers/     urls, healthz
 ├─ httpx/        error responses
 └─ migrations/   plain .up / .down SQL

§03 hard parts

The hard parts

  1. 01

    Dropping NestJS habits

    A lot of what I'm used to from NestJS, like decorators and a DI container, just isn't how Go code is written. Errors get returned and checked everywhere instead of thrown.

stack

  • Go
  • PostgreSQL
  • pgx
  • golang-migrate

next →

valve

A Node.js library that keeps your workers under the same API limit, with separate limits per tenant or recipient.