Notice: [Demo] Sample data is ready

PostOne

Go 置顶

How I organize handlers and middleware after Go 1.22

2026-11-03 15:04 17 0

Context

Monolith routes grow into god-files fast.

Approach

  1. Split by domain: auth.go, post.go, admin.go
  2. Inject deps on App, avoid globals
  3. One JSON envelope for writes

Takeaway

Readability beats cleverness; keep prepared statements and session isolation.

Comments Default: by hot

Log in to join the discussion

  • Alice #52 Top pick

    We split handlers by domain too—agreed.

  • Carol #53

    Frontend folks can navigate the tree.

  • Dave #54

    Any middleware ordering write-ups?