Logo vun Go Style Guide

Go Style Guide

Communautéit
madflojo
go-style-guide

Provides Go (Golang) engineering guidance for designing packages, services, and CLIs. Use whenever the task involves Go implementation, refactors, code reviews, API design, package layout, interfaces, constructors/config, error handling, logging, dependency or framework selection, HTTP/service wiring, concurrency/lifecycle, tests, benchmarks, godoc, or maintainability decisions.

Iwwersiicht

Editeurmadflojo
Repositorygo-style-agent-skill
Skill-Nummgo-style-guide
Stären
41
Forks
3
Matgeliwwert Fichieren
10
LizenzApache-2.0
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 10 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    Vum madflojo op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Go Style Guide an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/madflojo/go-style-agent-skill/tree/main/skills/go-style-guide
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/madflojo/go-style-agent-skill.git /tmp/go-style-agent-skill
mkdir -p .claude/skills
cp -r /tmp/go-style-agent-skill/skills/go-style-guide .claude/skills/go-style-guide
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Go Style Guide an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Go Style Guide automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Go Style Guide net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Go (Golang) Style Guide Skill

This skill defines practical Go engineering conventions for humans, coding agents, and production-ready systems.

Use this skill whenever you are working with Go: new code, refactors, reviews, architecture decisions, package design, or test strategy.


TL;DR

  • Design for testability first; inject dependencies and keep logic pure.
  • Prefer Config in -> concrete struct out; validate, default, and document important runtime knobs.
  • Errors are contracts: use sentinels for durable branching; wrap the rest with %w or errors.Join.
  • Keep packages reusable: no hidden globals, no default logging, no surprise side effects.
  • Prefer the standard library before adding dependencies; third-party packages must earn their weight through meaningful, maintained, adopted abstraction.
  • Coverage is a signal, not proof; test edge cases and misuse paths, not just happy paths.
  • Follow "accept interfaces, return structs"; consumers usually define interfaces, shared contract packages are a special case.
  • Keep main.go thin; follow existing repo layout conventions rather than forcing one directory shape.
  • Benchmark hot paths before claiming wins, and run concurrency code with -race.
  • Maintain contracts such as function signatures, config shape, error behavior, and doc comments; they are as important as the code itself.

House Style Disclaimer

This is intentionally opinionated. It favors consistency and long-term maintainability over accommodating every Go style preference. If the target repo has clear local conventions, those conventions usually win.


Compatibility

Examples assume modern Go and use standard-library features such as errors.Join and log/slog. Apply the guide within the constraints of the target repository's supported Go version.


Execution Protocol

Follow this workflow when using the skill for implementation work:

  1. Inspect the repository first. Read existing package layout, constructors, tests, and error conventions before proposing new APIs or moving files.

  2. Define the contract before coding. Decide the package boundary, config shape, concrete return type, sentinel errors, dependency seams, and context or shutdown expectations up front.

  3. Write or update tests early when practical. Start with table-driven unit tests, add fuzz tests for parsing or other input-heavy code, and add benchmarks for performance-sensitive paths.

  4. Implement the smallest maintainable change. Follow the repository's existing layout, keep main.go thin, and avoid introducing new abstractions without a clear boundary.

  5. Run the finishing checks. Format with gofmt (and goimports if the repo uses it), run the relevant go test targets, run go test -race when concurrency is involved, and run benchmarks when claiming performance improvements.

  6. Verify the human-facing contract. Make sure docs, comments, config defaults, and error behavior match the code you are shipping.


Quick Rules Table

TopicRuleReference
TestabilityDesign for confidence, not coverage percentages; test edge and misuse casesreferences/TESTING.md
ConstructorsConfig in -> concrete struct out; validate + default in New; use Config.Validate() when config logic growsreferences/CONFIG.md
ErrorsUse sentinels for durable branching; wrap with %w or errors.Join; keep recover at app boundariesreferences/ERRORS.md
LoggingPackages do not log by default; hot-path logging is a performance decisionreferences/LOGGING.md
DependenciesStandard library first; add third-party packages only when they provide meaningful, maintained valuereferences/LAYOUT.md
Interfaces"Accept interfaces, return structs"; consumers usually define interfacesreferences/INTERFACES.md
DocumentationWrite idiomatic godoc and durable comments; never add agent-context commentsreferences/DOCUMENTATION.md
LayoutKeep packages shallow, avoid junk drawers, and follow repo conventionsreferences/LAYOUT.md
Entry Pointsmain.go is wiring onlyreferences/LAYOUT.md
BenchmarksBenchmark hot paths; use b.ReportAllocs() and compare runs with benchstatreferences/BENCHMARKS.md
TestingTable-driven, stdlib-first, defensive against misuse, and fuzz-heavy where inputs are complexreferences/TESTING.md
ConcurrencyEvery goroutine needs a shutdown path; use context.Context, -race, and jitter where neededreferences/CONCURRENCY.md
ReviewsUse the checklist when reviewing Go changesreferences/REVIEW-CHECKLIST.md

Common Pitfalls

  • Returning interfaces by default instead of concrete types.
  • Treating coverage percentages as proof of correctness.
  • Logging in reusable packages instead of returning errors.
  • Adding frameworks or helper libraries when the standard library is already clear enough.
  • Passing global app config through packages rather than local Config.
  • Leaving critical runtime knobs on dangerous defaults.
  • Forcing a house directory layout onto repos that already have clear conventions.
  • Loading every reference document before you know which topic the task touches.
  • Shipping changes that claim performance wins without benchmarks or concurrency safety without -race.

Core Guidance

Load reference files only when the task needs that topic's detail.

  • App packages own dependency wiring, lifecycle, error policy, logging, and metrics policy.
  • Reusable packages return errors, define local Config or Opts, accept initialized dependencies, and avoid hidden logging or global state.
  • Dependency choices should start with the standard library. Reach for a third-party package only when it solves a real problem, is actively maintained, and earns its transitive cost.
  • Services usually keep cmd/<appname>/main.go thin. Follow established repo layout over forcing pkg/, internal/, or any house shape.
  • Libraries usually keep packages shallow and domain-focused.
  • Constructors prefer New(cfg Config) (*T, error), explicit defaults, validation, concrete returns, and immutable normalized config.
  • Interfaces should be small, boundary-driven, and usually consumer-defined.
  • Tests should be table-driven, stdlib-first, defensive, and run with -race for concurrency-sensitive code.
  • Performance claims need benchmarks.
  • Docs, comments, config defaults, error behavior, and signatures are part of the contract.

Reference Loading

Load only the references needed for the active task:

  • Read references/CONFIG.md for constructors, Config structs, defaults, validation, degraded modes, or logging injection.
  • Read references/INTERFACES.md for interface boundaries, driver patterns, mocks/fakes, or concrete return decisions.
  • Read references/ERRORS.md for sentinel errors, wrapping, typed errors, recover placement, or constructor failures.
  • Read references/LOGGING.md for package logging, slog, log levels, async error surfaces, or payload safety.
  • Read references/TESTING.md for table-driven tests, fuzzing, testdata, integration gates, test helpers, or assertion choices.
  • Read references/CONCURRENCY.md for goroutines, context propagation, graceful shutdown, mutex/atomic/channel choices, jitter, or race testing.
  • Read references/LAYOUT.md for package layout, file naming, main.go, dependency hygiene, struct field layout, or export rules.
  • Read references/DOCUMENTATION.md for package docs, godoc, examples, deprecations, internal comments, or field docs.
  • Read references/BENCHMARKS.md for benchmark shape, allocation reporting, concurrent benchmarks, IO benchmarks, or benchstat.
  • Read references/REVIEW-CHECKLIST.md when reviewing a Go PR or doing a final self-check.

Matgeliwwert Fichieren

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Go Style Guide?

Provides Go (Golang) engineering guidance for designing packages, services, and CLIs. Use whenever the task involves Go implementation, refactors, code reviews, API design, package layout, interfaces, constructors/config, error handling, logging, dependency or framework selection, HTTP/service wiring, concurrency/lifecycle, tests, benchmarks, godoc, or maintainability decisions.

Firwat Go Style Guide op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Go Style Guide besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Go Style Guide an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/madflojo/go-style-agent-skill/tree/main/skills/go-style-guide an. TypingMind liest d'Datei SKILL.md, bündelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Go Style Guide benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Go Style Guide benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Go Style Guide domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Go Style Guide gratis?

Jo. De Skill gëtt vum madflojo ënner der Lizenz Apache-2.0 op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇