Skip to content

gox Architecture

Module

github.com/sahilkhaire/gox — Go 1.22+

Folder rules

  1. Public packages live at the module root (http/, slice/, …). Import path = directory name.
  2. Nesting only when a domain outgrows one package (e.g. http/middleware/).
  3. internal/ holds private code shared by 2+ packages. Not importable externally.
  4. examples/ — one subdirectory per shipped feature; no empty placeholders.
  5. docs/ — plans, architecture, API mapping. Root keeps only README.md.
  6. No pkg/ or cmd/ unless explicitly needed later.

Conventions

RuleDetail
ContextI/O functions take context.Context as the first argument
ErrorsReturn errors; Must* helpers may panic (documented)
GenericsCollection helpers use type parameters
TestsStdlib testing only; table-driven tests
ImportsNo cycles between public packages
Node docsExported symbols include // Node: ... where applicable

Dependency policy

CategoryPolicy
Utilities & I/Ostdlib only
Web, data, security, infrastructureThin wrappers over proven libraries; justify in this file

Approved dependencies

PackageDependencyReason
gox/httpgithub.com/go-chi/chi/v5stdlib-compatible router
gox/validategithub.com/go-playground/validator/v10validation engine
gox/dbgithub.com/jmoiron/sqlxSQL ergonomics
gox/redisgithub.com/redis/go-redis/v9Redis client
gox/mongogo.mongodb.org/mongo-driverMongoDB client
gox/jwtgithub.com/golang-jwt/jwt/v5JWT
gox/crongithub.com/robfig/cron/v3Cron scheduling
gox/queuegithub.com/hibiken/asynqRedis task queue (Bull-like)
gox/semvergithub.com/Masterminds/semver/v3Semantic versioning
gox/wsgithub.com/gorilla/websocketWebSocket upgrade and framing
gox/http (rate limit)golang.org/x/time/rateToken-bucket rate limiting

Packages using stdlib only include gox/archive, gox/csv, gox/exec, gox/osutil, gox/cache, gox/event, gox/mail (net/smtp), gox/compress (compress/gzip), gox/stream (io), and gox/time (package timex). gox/http upload, session, and SSE features use stdlib multipart and cookies.

New dependencies require a row in this table before merge.

Adding a new package

  1. Create /<pkg>/ with doc.go, implementation, tests
  2. Add section to docs/node-mapping.md
  3. Mark shipped in docs/feature-catalog.md
  4. Add examples/<pkg>/ if the API is non-trivial

Test-only dependencies

PackageDependencyReason
gox/db testsmodernc.org/sqliteIn-memory SQLite without CGO
gox/redis testsgithub.com/alicebob/miniredis/v2Embedded Redis for unit tests
gox/queue testsgithub.com/alicebob/miniredis/v2Embedded Redis for asynq client/worker tests
gox/cryptogolang.org/x/crypto/bcryptPassword hashing
gox/idgithub.com/google/uuidUUID generation

MIT Licensed · Built for Node.js developers moving to Go