Guidance for structuring Go packages, grouping imports, and avoiding init and os.Exit outside main.

skills.sh installs
1.3K
GitHub stars
196
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers package naming and sizing, import grouping and aliasing, init() avoidance, and exits confined to main
  • Includes references/IMPORTS.md for import details and references/PACKAGE-SIZE.md for splitting packages and CLI flags
  • Enforces rules such as no util packages, no dot imports outside circular-dependency tests, and a run() pattern in main
  • Designed for Go projects starting fresh or splitting a growing codebase, with pointers to go-naming and go-linting for adjacent concerns

Install

$ npx -y skills add cxuu/golang-skills --skill go-packages -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Go Packages and Imports

Resource Routing

  • references/IMPORTS.md - Read when grouping imports, using blank imports, dot imports, or import aliases.
  • references/PACKAGE-SIZE.md - Read when splitting packages, avoiding init, structuring main, or designing CLI flags/subcommands.

When this skill does NOT apply: For naming individual identifiers within a package, see go-naming. For organizing functions within a single file, see go-functions. For configuring linters that enforce import rules, see go-linting.

Package Organization

Avoid Util Packages

Package names should describe what the package provides. Avoid generic names like util, helper, common — they obscure meaning and cause import conflicts.

// Good: Meaningful package names
db := spannertest.NewDatabaseFromFile(...)
_, err := f.Seek(0, io.SeekStart)

// Bad: Vague names obscure meaning
db := test.NewDatabaseFromFile(...)
_, err := f.Seek(0, common.SeekStart)

Generic names can be used as part of a name (e.g., stringutil) but should not be the entire package name.

Package Size

Details

Repository
github.com/cxuu/golang-skills
Categories
Go, Code Review & Quality
First seen
May 16, 2026

More from cxuu/golang-skills

All 20

Similar to Go Packages

More Go