
Go Functions
Covers the mechanics of writing and organizing Go functions: signature formatting, call ordering, receiver grouping, and when to wrap long parameter lists. Includes guidance on pointers to interfaces (you almost never need them), Printf-style naming conventions for format string functions, and using %q over %s for safer string formatting in logs and errors. The file ordering rules are especially practical: types first, then constructors, exported methods, unexported ones, then utilities. It deliberately excludes functional options constructors and error handling patterns, which have their own dedicated skills. If you're refactoring a Go file and wondering where functions should live or how to format a ten-parameter signature, this is the reference.
- skills.sh installs
- 1.1K
- GitHub stars
- 193
- last updated
- Aug 21, 2026
Install
$ npx -y skills add cxuu/golang-skills --skill go-functions --agent claude-codeInstalls into .claude/skills of the current project.
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:
- Functions sorted in rough call order
- Functions grouped by receiver
- Exported functions appear first, after
struct/const/vardefinitions NewXxx/newXxxconstructors appear right after the type definition- 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() { ... }
Sponsors
Details
- Repository
- github.com/cxuu/golang-skills
- Categories
- Code Review & Quality, Go, Design & UI/UX
- First seen
- Jun 3, 2026
More from cxuu/golang-skills
All 20- Go Generics1.1K
- Go Declarations1.1K
- Go Code Review1.8K
- Go Testing1.4K
- Go Error Handling1.3K
- Go Linting1.3K
- Go Concurrency1.3K
- Go Interfaces1.3K
- Go Documentation1.3K
- Go Style Core1.3K
- Go Performance1.3K
- Go Context1.3K
- Go Naming1.3K
- Go Defensive1.3K
- Go Packages1.3K
- Go Data Structures1.3K
- Go Functional Options1.3K
- Go Control Flow1.3K
- Go Logging1.1K