Go Project Layout

Guides how a Go module is organized into directories and packages — start flat (a single package at the module root is fine; don't build a deep tree prematurely), put each binary behind cmd/name/main.go and keep main thin (parse flags, wire dependencies, delegate to importable packages so the logic is testable), use internal/ for compiler-enforced privacy to keep an API surface small, package by responsibility/capability not by MVC layer (no models//controllers//services/), never create a util/common/helpers/shared grab-bag named for what it holds instead of what it does, don't treat the community golang-standards/project-layout repo as official, and don't reach for pkg/ by reflex. Auto-invokes when creating a new Go project/module structure, adding packages or directories, cmd/ or internal/ dirs, or on "how should I structure this", "where does this code go", or "do I need a pkg/ folder". The official guidance is go.dev/doc/modules/layout, and it is minimal.

ctoth 7305a7c 3 files · 36.2 KB Updated

File contents

ctoth/golang-skills-plugin/tree/main/plugins/golang/skills/go-project-layout commit 7305a7c3cd

Frequently asked questions

npx skillmds@latest add ctoth/go-project-layout