askill
go-patterns

go-patternsSafety 95Repository

Go patterns and idioms. Use when writing, reviewing, or refactoring Go code. Covers error handling, concurrency, testing, and project structure.

0 stars
1.2k downloads
Updated 2/22/2026

Package Files

Loading files...
SKILL.md

Go Patterns

Authoritative reference for idiomatic Go (1.21+). Each reference file is self-contained and can be loaded independently.


When to Use

  • Writing new Go packages or services
  • Reviewing Go PRs for correctness and idioms
  • Refactoring existing Go code toward idiomatic style
  • Setting up a new Go module or project layout
  • Debugging Go-specific issues (goroutine leaks, race conditions, error chain)

Quick Reference

TopicReference FileContents
Core idiomsreferences/idiomatic-go.mdInterfaces, zero values, composition, generics
Error handlingreferences/error-handling.mdWrapping, sentinel errors, custom types, errors.Is/As
Concurrencyreferences/concurrency.mdGoroutines, channels, errgroup, context, race detection
Testingreferences/testing.mdTable-driven tests, testify, race detector, mocks
Project structurereferences/project-structure.mdModule layout, internal/, package naming

Limited Context Strategy

When context is tight, load only what you need:

  • Most tasks: idiomatic-go.md + error-handling.md
  • Concurrent code: add concurrency.md
  • Test writing/review: add testing.md
  • New project setup: project-structure.md only

Overview

Go prioritizes simplicity, readability, and explicit behavior. The language design discourages clever abstractions and encourages:

  • Small, composable interfaces
  • Errors as values, not exceptions
  • Concurrency via communicating sequential processes (CSP)
  • A single idiomatic way to do most things (gofmt, standard project layout)

The compiler and toolchain enforce many conventions. Treat go vet, golangci-lint, and the race detector as authoritative.


Tooling Quick Reference

ToolCommandPurpose
gofmtgofmt -w .Format (no configuration)
goimportsgoimports -w .Format + organize imports
go vetgo vet ./...Catch common mistakes
golangci-lintgolangci-lint run ./...Aggregated linters
go testgo test -race -count=1 ./...Tests with race detection
go buildgo build ./...Compile-check all packages
go mod tidygo mod tidySync go.mod and go.sum

Triggers

TriggerExample
Writing Go code"implement a worker pool in Go"
Reviewing Go PRs"review this Go handler"
Error handling questions"how should I wrap this error?"
Concurrency design"design a pipeline with context cancellation"
Project setup"structure a new Go service"

Key Terms

TermDefinition
Interface satisfactionImplicit in Go — any type with the right methods satisfies an interface
Zero valueDefault value for a type when declared without initialization
GoroutineLightweight concurrent execution unit managed by the Go runtime
ChannelTyped conduit for communicating between goroutines
errgroupgolang.org/x/sync/errgroup — manages a group of goroutines with error propagation
Sentinel errorA package-level var ErrX = errors.New("x") used for error identity checks
%w verbWraps an error so errors.Is/errors.As can unwrap the chain

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

82/100Analyzed 2/25/2026

High-quality reference skill for Go patterns with excellent structure, clear triggers, and comprehensive quick references. Acts as an index to detailed reference files. Scores well on clarity, safety, and reusability. Actionability slightly reduced because detailed content is in external files. No internal-only indicators.

95
90
85
80
65

Metadata

Licenseunknown
Version-
Updated2/22/2026
PublisherTrevorEdris

Tags

ci-cdlintingtesting