Skillshub golang-language
Core idioms, style guides, and best practices for writing idiomatic Go code. Use when writing Go code following official style guides and idiomatic patterns. (triggers: go.mod, golang, go code, idiomatic, gofmt, goimports, iota, golang style)
install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/HoangNguyen0403/agent-skills-standard/golang-language" ~/.claude/skills/comeonoliver-skillshub-golang-language && rm -rf "$T"
manifest:
skills/HoangNguyen0403/agent-skills-standard/golang-language/SKILL.mdsource content
Golang Language Standards
Priority: P0 (CRITICAL)
Guidelines
- Formatting: Run
orgofmt
on save. Usegoimports
for LSP features.gopls - Naming: Use
for internal (unexported) andcamelCase
for public (exported) symbols.PascalCase - Packages: Use short, lowercase, singular names (e.g.,
,http
). Avoiduser
or_
in package names.camelCase - Interfaces: Small interfaces — 1-2 methods max. Define where used (consumer side), not where implemented.
- Errors: Return
as the last return value. Handle errors immediately at the call-site.error - Slices: Use
to pre-allocate capacity and avoid redundant re-allocations.make(slice, len, cap) - Enums: Use a const block with iota for type-safe enumerations.
- Zero Values: Leverage
initialization over explicitzero-value
checks where possible.nil
Anti-Patterns
- No init: Use constructors (NewService()), not init(). (not init() — it runs implicitly and makes testing harder)
- No Globals: Use DI, not global mutable state.
- No
: Return errors, don't panic.panic - No
ignored errors: Always check and handle errors._ - No stutter:
, notlog.Error
.log.LogError
Verification Workflow (Mandatory)
After writing or modifying Go code:
— catch compile errors and gopls type diagnostics immediatelymcp__ide__getDiagnostics
— catch common mistakes (printf mismatches, unreachable code, shadowed vars)go vet ./...
— fix imports and formatting in one passgoimports -w .