Trust is earned, not given

A different perspective

2023-09-16 · Projects

GoShop: learning Go by building a 40-endpoint shopping backend

GoLang (the GoShop sample) is a complete shopping-site backend in a single Go binary: customers with JWT auth and TOTP two-factor, products, cart, orders, payments, shipping — reading from Redis, writing to PostgreSQL, with migrations embedded and applied at startup.

Why Go feels different, and why that is the point

Go has no classes, no inheritance, no exceptions. The sample leans into that: domains are plain packages under internal/, errors are values you check and wrap (if err != nil), and concurrency is goroutines with channels. Coming from C# or Java, the first week feels restrictive; the second week you notice your code has fewer layers and fewer surprises. The stack — chi router, pgx pool, go-redis, JWT HS256, bcrypt — is the standard library-plus-small-packages idiom, deliberately free of "framework magic".

Patterns worth studying in the code

Repo layout as a map

cmd/server (the entrypoint), internal/api (routing/middleware), internal/<domain> (customers, products, cart, orders, payments, shipping), internal/store (Postgres/Redis seams). If you have read the Node.js GoShop article, you will recognise the same domain split in a different language — that parallelism is deliberate.

Repository: github.com/bobhuang1/GoLang