Skip to content
cxuu avatar

Go Functions

Go function design rules covering file ordering, signature wrapping, interface parameters, and Printf-style naming.

CCM score
65 of 100
skills.sh installs
1.1K
GitHub stars
197
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers function grouping and ordering in Go files: call order, receiver grouping, exported-first, and constructors placed after their types
  • Includes signature formatting rules for wrapped parameter lists, /* name */ comments for ambiguous arguments, and custom types in place of naked bools
  • Enforces passing interfaces by value rather than as pointers, and f-suffixed names for Printf-style functions to support go vet
  • Designed for Go developers writing or refactoring functions, with routing to related skills for error returns, naming, and functional options

Install

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

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

Files

Go Function Design

Resource Routing

  • references/SIGNATURES.md - Read when designing parameters, return values, named results, or signature readability.
  • references/PRINTF-STRINGER.md - Read when using fmt verbs, Stringer, GoStringer, Formatter, or Printf-style function naming.

When this skill does NOT apply: For functional options constructors (WithTimeout, WithLogger), see go-functional-options. For error return conventions, see go-error-handling. For naming functions and methods, see go-naming.


Function Grouping and Ordering

Organize functions in a file by these rules:

  1. Functions sorted in rough call order
  2. Functions grouped by receiver
  3. Exported functions appear first, after struct/const/var definitions
  4. NewXxx/newXxx constructors appear right after the type definition
  5. Plain utility functions appear toward the end of the file
type something struct{ ... }

func newSomething() *something { return &something{} }

func (s *something) Cost() int { return calcCost(s.weights) }

func (s *something) Stop() { ... }

Details

Repository
github.com/cxuu/golang-skills
Category
Go
First seen
Jun 3, 2026

More from cxuu/golang-skills

All 20

Similar to Go Functions

More Go