Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

golang-patterns

/golang-patterns

Stosuje idiomatyczne wzorce Go przy pisaniu, przeglądzie i refaktoryzacji API, pakietów, błędów i współbieżności.

Repozytorium
malskill ↗
Licencja
MIT
Ostatnia zmiana repozytorium
13.11.2026

Ocena i bezpieczeństwo

90/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść25 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
14
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 13.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Stosuje idiomatyczne wzorce Go przy pisaniu, przeglądzie i refaktoryzacji API, pakietów, błędów i współbieżności.

Oryginalny opis (EN)

Idiomatic Go patterns, best practices, and conventions for building robust, readable, and maintainable Go code. Use when writing, reviewing, or refactoring Go (APIs, packages, errors, interfaces, concurrency, code style), choosing a dispatch or plugin mechanism, or building low-level/offensive Go with `unsafe`, `cgo`, syscall dispatch, or RE-resistant static builds.

Jak działa

  1. When to activate
  2. Core principles (high signal)
  3. Outcome expectations
  4. Recommended workflow
  5. Quick review checklist
  6. Common anti-patterns to reject
  7. Resources
Sekcje z nagłówków SKILL.md, w oryginale · 86 linii, 552 słów
Podgląd SKILL.md
---
name: golang-patterns
description: "Idiomatic Go patterns, best practices, and conventions for building robust, readable, and maintainable Go code. Use when writing, reviewing, or refactoring Go (APIs, packages, errors, interfaces, concurrency, code style), choosing a dispatch or plugin mechanism, or building low-level/offensive Go with `unsafe`, `cgo`, syscall dispatch, or RE-resistant static builds."
license: MIT
compatibility: "Go 1.22+ (guidance baseline; notes flag features through Go 1.27). Optional tools: gofmt, goimports, staticcheck, golangci-lint, gopls, govulncheck, gosec, garble."
metadata:
  author: AeonDave
  version: "1.6"
---

# Go Patterns

This skill focuses on **idiomatic Go design and code review guidance**.

If your task is primarily measurement/profiling/optimization, use `golang-performance`.

## When to activate

- Writing new Go code (packages, APIs, services)
- Reviewing PRs for idioms, readability, and maintainability
- Refactoring for cleaner error handling and smaller interfaces
- Designing concurrency flows with cancellation and backpressure
- Choosing a dispatch/plugin mechanism, adding modules to a compiled binary, or building low-level/offensive Go tooling

---

## Core principles (high signal)

- **gofmt is non-negotiable.** Style debates end at `gofmt`.
- Prefer **clarity**: small functions, early returns, explicit control flow.
- Make the **zero value useful**.
- Keep **interfaces small**; define them where they’re consumed.
- Handle **errors explicitly**; wrap with context; avoid `panic` for control flow.
- Concurrency should be **bounded** and **cancellable**; avoid goroutine leaks.

---

## Outcome expectations

- Public APIs are small, explicit, and boring to maintain.
- Error handling is consistent and machine-checkable with `errors.Is` / `errors.AsType`.
- Concurrency flows always have cancellation and backpressure.
- Tooling baseline (`gofmt`, tests, vet/race) is easy to run in CI.

---

## Recommended workflow

1. Define package boundary + API contracts (inputs, outputs, errors) first.
2. Implement with small functions and explicit control flow.
3. Add context propagation and cancellation checks on blocking operations.
4. Run formatting/tests/vet/race before review.
5. Review for leaks, hidden globals, and interface over-abstraction.

---

## Quick review checklist

- Naming: MixedCaps for exported, no underscores, packages short and lower-case
- Errors: `fmt.Errorf("context: %w", err)`, `errors.Is` / `errors.AsType` (Go 1.26+) used correctly
- Context: `ctx` is first param; cancellation propagates; no `context.Context` stored in structs
- Interfaces: accept interfaces, return concrete types; no “kitchen-sink” interfaces
- Concurrency: goroutines have a stop condition; channels are closed by senders; backpressure exists
- Tooling: `go test ./...`, `go test -race ./...`, `go vet ./...`

---

## Common anti-patterns to reject

- Storing `context.Context` in structs
- Unbounded goroutine fan-out in request paths
- Catch-all interfaces like `Doer`, `Manager`, `Service` without clear boundary
- Returning wrapped errors without enough domain context
- Package-level mutable state hidden behind helper functions

---

## Resources

Load on demand (progressive disclosure):

- `references/effective-go.md` — distilled Effective Go + Code Review Comments pointers
- `references/language.md` — load when using loop-var/range-over-func semantics, `new(expr)`, self-referential constraints, generic methods, embedded-field keys, or 1.27 type inference
- `references/json-v2.md` — load when adding or migrating JSON (`encoding/json` vs `encoding/json/v2`, `omitzero`, stricter defaults)
- `references/errors.md` — wrapping, sentinel vs typed errors, `errors.AsType`, validation, retryable errors
- `references/interfaces.md` — interface placement, design patterns, optional behavior, generic-method vs interface-method rule
- `references/concurrency.md` — cancellation, errgroup, leaks, worker pools, backpressure, timer-channel semantics
- `references/api-and-structs.md` — receiver rules, functional options, embedding, ServeMux patterns
- `references/package-layout.md` — project layout, package naming, dependency injection
- `references/tooling.md` — gofmt/goimports, vet, `go fix`, language version via the `go` directive
- `references/security-review.md` — use when auditing Go for security bugs: untrusted input, panics/DoS, TLS defaults, secrets, supply chain (`govulncheck`, `gosec`)
- `references/unsafe-cgo.md` — use for `unsafe.Pointer` rules, `syscall`/`x/sys`, cgo boundaries, and static/cross-compiled offensive-tooling builds
- `references/dispatch-and-plugins.md` — use when choosing `dyn` interfaces vs enum dispatch, building registries and command dispatchers, or adding modules to a compiled binary (`plugin`, `hashicorp/go-plugin`, `wazero`/`extism`, `yaegi`, `selfupdate`, `tableflip`)
- `references/offensive-lowlevel.md` — use for RE-resistance, symbol/metadata stripping, `garble`/`GoReSym`, string obfuscation, syscall dispatch strategy, and in-memory execution
Pliki w paczce (14)
  • SKILL.md 5 KB
  • references/api-and-structs.md 2 KB
  • references/concurrency.md 4 KB
  • references/dispatch-and-plugins.md 11 KB
  • references/effective-go.md 4 KB
  • references/errors.md 3 KB
  • references/interfaces.md 2 KB
  • references/json-v2.md 4 KB
  • references/language.md 6 KB
  • references/offensive-lowlevel.md 11 KB
  • references/package-layout.md 1 KB
  • references/security-review.md 9 KB
  • references/tooling.md 2 KB
  • references/unsafe-cgo.md 9 KB

Wersje

RepozytoriumWynikLicencja
Ta strona · aeondave/malskill90MIT
affaan-m/ECC100MIT
kannnnna9/ultracode95MIT
affaan-m/ECC95MIT
SHRIJANAGAIN/Nemo-Cli95Apache-2.0
j4flmao/agent-skills90MIT

Migawka bazy z 13.11.2026 · wersja paczki ee5dbd184004 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 1 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100dotnet-patterns
    Podpowiada idiomatyczne wzorce C# i .NET, konwencje, wstrzykiwanie zależności i async/await przy pisaniu lub przeglądzie kodu.
  • 95kotlin-patterns
    Podpowiada idiomatyczne wzorce Kotlina: korutyny, bezpieczeństwo wartości null i buildery DSL, przy pisaniu i przeglądzie kodu.
  • 100go-best-practices
    Podpowiada wzorce produkcyjne w Go: cykl życia, współbieżność, konfigurację, testy i CI przy pisaniu i przeglądzie kodu.
  • 100dotnet-patterns
    Opisuje idiomatyczne wzorce i konwencje C# i .NET: wstrzykiwanie zależności, async/await i dobre praktyki budowy utrzymywalnych aplikacji.
  • 100golang-modernize
    Unowocześnia kod Go o nowsze cechy języka, usprawnienia biblioteki standardowej i idiomatyczne wzorce, także przy ostrzeżeniach o przestarzałych API i podniesieniu wersji Go.
  • 100golang
    Określa konwencje Go obowiązujące w projekcie, które odbiegają od powszechnej praktyki, przy pisaniu, przeglądzie i refaktoryzacji kodu źródłowego i testów.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.