Logo: Go Naming

Go Naming

Communautéit
eduardo-sl
go-naming

Go naming conventions for packages, files, types, functions, methods, receivers, variables, constants, errors, acronyms and tests, grounded in Effective Go and Go Code Review Comments. Use when: "what should I name this", "name this package", "naming review", "is this name idiomatic", "stuttering names", "Get prefix", "acronym casing", "error variable name", "receiver name". Not for: formatting, imports and declarations (go-coding-standards), carrying out a rename across the codebase (go-semantic-tools, go-refactoring).

Iwwersiicht

Editeureduardo-sl
Repositorygo-agent-skills
Skill-Nummgo-naming
Stären
86
Forks
11
Matgeliwwert Dateien
1
LizenzMIT
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.

  • 1 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

    eduardo-sl huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Go Naming an TypingMind, fir e mat all LLM ze benotzen, oder setzt 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 „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/eduardo-sl/go-agent-skills/tree/main/skills/(code-quality)/go-naming
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.

An TypingMind benotzen

Aktivéiert Go Naming 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 Naming 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 Naming 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-Schlësselen.

  • 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 Naming

In Go the package name is part of every call site, capitalization decides visibility, and short names are the norm. A good name reads well where it is used, not where it is declared.

Community default. A project skill or agent-config rule that explicitly supersedes go-naming takes precedence over this one.

Detailed reference material, loaded on demand:

  • references/examples.md — before/after renames for every rule below, including the initialism and stuttering edge cases.

Read a reference file only when the summary below is not enough.

1. Quick Reference

ElementConventionExample
Packageshort, lowercase, one word, singularorder, httpsign, postgres
Filelowercase, _ allowed, named after its main type or concernorder_service.go, order_service_test.go
Exported identifierMixedCapsParseToken, MaxRetries
Unexported identifiermixedCapsparseToken, maxRetries
Initialismall one caseURL, userID, ServeHTTP, xmlParser
Getter / setterOwner() / SetOwner()never GetOwner()
ConstructorNew for the package's main type, NewThing otherwisering.New, http.NewRequest
Panicking variantMust prefixtemplate.Must, regexp.MustCompile
Functional optionWith + settingWithTimeout, WithLogger
One-method interfacemethod + -erReader, Notifier
Receiver1-2 letters, same on every methodfunc (s *Server)
Sentinel errorErr prefix (err unexported)ErrNotFound, errClosed
Error typeError suffixValidationError
Enum constanttype name prefix, zero = unknownStatusUnknown, StatusActive
TestTest + function, Test + type _ methodTestParse, TestCache_Get

2. Packages

  • Short, lowercase, single word: no underscores, no mixedCaps, no plural (order, not orders).
  • Name it after what it provides: retry, httpsign, postgres. Never util, common, helpers, misc, base, models, types — they say nothing and collect everything.
  • The directory name and the package name match.
  • Avoid names callers want for their variables (url, user, buf) when the package is imported widely; a call site with u := user.New() reads better than shadowing the package.

3. Don't Stutter

The package name is always present at the call site, so don't repeat it:

go
// ✅ Good — reads once
http.Client       order.Service     user.New()     config.Load()

// ❌ Bad — says it twice
http.HTTPClient   order.OrderService user.NewUser() config.LoadConfig()

The rule covers every exported name in the package, not just the main type: in package dbpool, Pool, Status and Option — not DBPool, PoolStatus, PoolOption.

4. MixedCaps, Initialisms and Constants

  • Every identifier is MixedCaps or mixedCaps. Underscores appear only in test names (TestCache_Get), generated code, and cgo.
  • An initialism keeps one case throughout: URL, ID, HTTP, JSON, API — userID, parseURL, ServeHTTP, HTTPServer, xmlHTTPRequest. Never UserId, ParseUrl, HttpServer.
  • Constants are MixedCaps like everything else: MaxRetries, not MAX_RETRIES — case already means "exported" in Go.
  • Name constants for their role, not their value: DefaultPort, not Port8080.
  • Do not shadow predeclared identifiers: len, cap, new, make, close, copy, error, string, min, max.

5. Functions and Methods

  • Getters drop Get: u.Name(), and the setter is u.SetName(). Is/Has/Can stay on boolean predicates: IsActive().
  • Constructors: New when the package has one main type, NewThing otherwise. A constructor that panics on bad input is MustThing.
  • Canonical names carry a contract. Call a method Read, Write, Close, Flush, String, Error or ServeHTTP only if it has the standard signature and meaning — and if it does, use that name (String(), never ToString()).
  • Name for what the caller gets, not how it is computed: Users(), not QueryAndBuildUserList().
  • Format-string variants end in f: Errorf, Logf.

6. Variables and Receivers

  • Name length grows with scope: i, n, err, ctx, buf inside a few lines; retryTimeout, pendingOrders across a function; full words at package level.
  • Don't put the type in the name (userSlice → users, nameStr → name), and don't repeat context the reader already has (order.ID inside type Order, not order.OrderID).
  • Receivers are one or two letters from the type (s *Server, rw *responseWriter), the same on every method of the type — never this or self.
  • Unexported package-level variables may take a _ prefix (_defaultTimeout) to keep them distinct from locals — the Uber style convention. Follow whichever the codebase already uses.
  • Boolean names read as a question: isReady, hasChildren, canRetry.

7. Types and Interfaces

  • Types are nouns: Request, FileHeader, RetryPolicy.
  • A one-method interface is the method plus -er: Reader, Notifier, Validator. Never an I prefix or Interface suffix.
  • Name an interface after the behavior the consumer needs, in the consumer's package (orderStore in the service), not after the implementation it happens to have.

8. Errors

  • Exported sentinels ErrNotFound, unexported errClosed.
  • Error types end in Error: NotFoundError, SyntaxError.
  • Error strings are lowercase with no trailing punctuation, prefixed with the package or operation: "order: invalid quantity". They get wrapped into longer messages, so they must read mid-sentence.

9. Enums and Tests

  • Enum constants are prefixed with their type and start with an explicit Unknown at zero: StatusUnknown, StatusActive, StatusClosed.
  • Tests: TestParse, TestCache_Get, BenchmarkParse, ExampleCache_Get (the example name must match a real identifier, or go vet complains).
  • Subtest names are short lowercase phrases — "empty input", "expired token" — because go test -run 'TestParse/empty_input' selects them.

Applying a Rename

Rename with gopls, not search-and-replace: it follows the type graph and refuses renames that would break interface satisfaction (the go-semantic-tools skill). Then grep struct tags, templates and SQL for the old name — gopls does not see them. Exported names in a published library need a deprecation cycle (the go-refactoring skill).

Verification Checklist

  1. No package named util, common, helpers, models, types, misc or base
  2. No exported name repeats its package name
  3. Initialisms keep one case (ID, URL, HTTP); no ALL_CAPS constants
  4. No Get prefix on getters; Must only on panicking functions
  5. Canonical method names (String, Read, Close, …) have canonical signatures
  6. Receivers are short and identical across a type's methods; no this/self
  7. Sentinels use Err, error types end in Error, error strings are lowercase
  8. Enum constants carry the type prefix and an Unknown zero value
  9. No predeclared identifier is shadowed
  10. Renames done with gopls; tags and templates checked afterwards

Matgeliwwert Dateien

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 Naming?

Go naming conventions for packages, files, types, functions, methods, receivers, variables, constants, errors, acronyms and tests, grounded in Effective Go and Go Code Review Comments. Use when: "what should I name this", "name this package", "naming review", "is this name idiomatic", "stuttering names", "Get prefix", "acronym casing", "error variable name", "receiver name". Not for: formatting, imports and declarations (go-coding-standards), carrying out a rename across the codebase (go-semantic-tools, go-refactoring).

Firwat Go Naming op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Go Naming 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 en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Go Naming an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/eduardo-sl/go-agent-skills/tree/main/skills/(code-quality)/go-naming 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 Naming 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 Naming benotzen?

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

Ass de KI-Skill Go Naming gratis?

Jo. eduardo-sl huet de Skill ënner der Lizenz MIT 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 weiderverwendbare Pak vun Instruktiounen, deen 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 e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

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