cxuu avatar

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-code

Installs 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:

  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() { ... }

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
1cxuu avatargo-declarationscxuu/golang-skillsUse when declaring or initializing Go variables, constants, structs, or maps — including var vs :=, reducing scope with if-init, formatting composite literals, 1.1Kskills.sh installs
2mblode avataragent-skills-creatormblode/agent-skillsGuides creation and improvement of best-practice agent skills following the open format specification. Covers frontmatter, progressive disclosure, reference fil1Kskills.sh installs
3inference-sh avatarnewsletter-curationinference-sh/skillsNewsletter curation with content sourcing, editorial structure, and subscriber growth strategies. Covers issue formatting, link roundups, commentary style, and 1Kskills.sh installs
4github avatarphoenix-cligithub/awesome-copilotDebug LLM applications using the Phoenix CLI. Fetch traces, analyze errors, structure trace review with open coding and axial coding, inspect datasets, review e1Kskills.sh installs
5microsoft avatarskill-authoringmicrosoft/github-copilot-for-azureGuidelines for writing Agent Skills that comply with the agentskills.io specification. WHEN: \"create a skill\", \"new skill\", \"write a skill\", \"skill templ1Kskills.sh installs
6daymade avatargithub-contributordaymade/claude-code-skillsEnd-to-end playbook for shipping high-quality pull requests to open-source projects you don't maintain — discovery, CONTRIBUTING compliance, PR-size check, mini991skills.sh installs