Synthèse automatique
Cette skill rappelle les conventions idiomatiques Go à respecter avant toute création ou modification de fichier .go : happy path, enrobage d'erreurs avec %w, erreurs sentinelles et commentaires de style godoc.
Points forts
- Donne des exemples correct/incorrect côte à côte, ce qui rend la règle immédiatement applicable
- Couvre les points où les LLM dérivent le plus souvent en Go : erreurs non enrobées, logique principale imbriquée dans des if err == nil, ombrage des identifiants prédéclarés
- Rappelle l'usage de errors.Is() avec des erreurs sentinelles déclarées au niveau du package
- Inclut les proverbes Go comme cadre mental (happy path, « Errors are values », « Don't panic »)
Limites
- C'est une liste de conventions en texte, sans outil de vérification automatique : rien ne garantit que le code produit sera conforme
- La liste des identifiants prédéclarés à éviter s'interrompt au niveau des types et reste donc incomplète
- N'aborde ni les tests, ni la structure de projet, ni les modules Go
À charger dès qu'une tâche implique d'écrire ou de modifier du code Go, pour que les conventions soient appliquées dès la première passe.
Inutile pour du code dans un autre langage, ou pour une simple relecture de prose sans production de fichiers .go.
Analyse de sécurité
SûrThis is a purely stylistic Go coding-conventions document. It contains no executable instructions beyond benign `go doc` documentation lookups, no file deletion, no network calls, no credential handling, and no attempt to disable safety mechanisms. The declared allowed-tools is empty, so there is no tool-execution surface at all.
Aucun point d'attention détecté
Comment cette analyse est faiteExemples
Write a GetUser function in internal/store/user.go that returns a package-level ErrNotFound sentinel when the record is missing and wraps any DB error with the user ID as context.Refactor my ProcessOrder function in order.go so the success path flows straight down instead of nesting the main logic inside if err == nil blocks.Review comment.go: make every comment end with a period, add a godoc comment on each exported function, and rename any parameter that shadows a Go predeclared identifier.name: golang-style
description:
Use this skill BEFORE writing or editing any Go (.go) files. Triggers when
about to create, modify, or add code to .go files. Enforces happy path coding,
error wrapping, sentinel errors, godoc-style comments, and go doc usage.
Go Coding Conventions
Proverbs
Try to follow the proverbs:
Go Proverbs Simple, Poetic, Pithy Don't communicate by sharing memory, share memory by communicating. Concurrency is not parallelism. Channels orchestrate; mutexes serialize. The bigger the interface, the weaker the abstraction. Make the zero value useful. interface{} says nothing. Gofmt's style is no one's favorite, yet gofmt is everyone's favorite. A little copying is better than a little dependency. Syscall must always be guarded with build tags. Cgo must always be guarded with build tags. Cgo is not Go. With the unsafe package there are no guarantees. Clear is better than clever. Reflection is never clear. Errors are values. Don't just check errors, handle them gracefully. Design the architecture, name the components, document the details. Documentation is for users. Don't panic.
Follow these conventions strictly when writing Go code.
Happy Path Coding
Structure code so the successful path flows straight down. Handle errors immediately, then continue with main logic.
// Correct: happy path flows down.
func ProcessUser(id string) (*User, error) {
user, err := db.GetUser(id)
if err != nil {
return nil, fmt.Errorf("get user %s: %w", id, err)
}
if err := user.Validate(); err != nil {
return nil, fmt.Errorf("validate user %s: %w", id, err)
}
return user, nil
}
// Wrong: main logic nested inside conditions.
func ProcessUser(id string) (*User, error) {
user, err := db.GetUser(id)
if err == nil {
if err := user.Validate(); err == nil {
return user, nil
} else {
return nil, err
}
}
return nil, err
}
Error Wrapping
Always wrap errors with context using %w. Include the operation and relevant
identifiers.
// Correct: wrapped with context.
if err != nil {
return fmt.Errorf("create order for customer %s: %w", customerID, err)
}
// Wrong: no context.
if err != nil {
return err
}
Sentinel Errors
Define package-level sentinel errors for expected error conditions. Use
errors.Is() to check.
// Define at package level.
var (
ErrNotFound = errors.New("not found")
ErrUnauthorized = errors.New("unauthorized")
ErrInvalidInput = errors.New("invalid input")
)
// Return sentinel errors.
func GetUser(id string) (*User, error) {
user := db.Find(id)
if user == nil {
return nil, ErrNotFound
}
return user, nil
}
// Check with errors.Is().
user, err := GetUser(id)
if errors.Is(err, ErrNotFound) {
// Handle not found case.
}
Comments
All comments end with a period.
// ProcessOrder handles order creation and validation.
func ProcessOrder(o *Order) error {
// Validate the order before processing.
if err := o.Validate(); err != nil {
return err
}
// Continue with order processing.
return nil
}
Naming Conventions
Never use Go's predeclared identifiers as variable or parameter names. These include built-in functions and constants that can be shadowed but should not be.
// Wrong: shadows built-in identifiers.
func process(new string, len int, make bool) error {
copy := "data"
return nil
}
// Correct: use descriptive names instead.
func process(name string, length int, shouldCreate bool) error {
dataCopy := "data"
return nil
}
Predeclared identifiers to avoid:
- Functions:
new,make,len,cap,append,copy,delete,close,panic,recover,print,println,complex,real,imag,clear,min,max - Constants:
true,false,iota,nil - Types:
error,bool,string,int,int8,int16,int32,int64,uint,uint8,uint16,uint32,uint64,uintptr,float32,float64,complex64,complex128,byte,rune,any,comparable
Line Length
Maximum line length is 120 characters. Break long lines at logical points.
// Correct: break at logical points.
func ProcessOrderWithValidation(
ctx context.Context,
order *Order,
validator OrderValidator,
) (*Result, error) {
return nil, fmt.Errorf(
"process order %s for customer %s: %w",
order.ID,
order.CustomerID,
err,
)
}
Documentation Lookup
Use go doc to look up standard library and package documentation:
go doc fmt.Errorf
go doc errors.Is
go doc context
Du fichier au premier essai
Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.
Consulter la source et ses fichiers annexesCe téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.
1. Télécharger le fichier
Télécharger SKILL.mdDepuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/go-coding-conventions-mrwakdbn/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.
Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.
mkdir -p '.skill-downloads/go-coding-conventions-mrwakdbn' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/go-coding-conventions-mrwakdbn/download' --output '.skill-downloads/go-coding-conventions-mrwakdbn/SKILL.md.part' && mv '.skill-downloads/go-coding-conventions-mrwakdbn/SKILL.md.part' '.skill-downloads/go-coding-conventions-mrwakdbn/SKILL.md'2. Vérifier les prérequis
Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.
Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.
Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.
3. Charger la skill
Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.
Claude Code
test -f '.skill-downloads/go-coding-conventions-mrwakdbn/SKILL.md' && test -s '.skill-downloads/go-coding-conventions-mrwakdbn/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/golang-style' && cp -R '.skill-downloads/go-coding-conventions-mrwakdbn' '.claude/skills/golang-style'Cursor
test -f '.skill-downloads/go-coding-conventions-mrwakdbn/SKILL.md' && test -s '.skill-downloads/go-coding-conventions-mrwakdbn/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/golang-style' && cp -R '.skill-downloads/go-coding-conventions-mrwakdbn' '.cursor/skills/golang-style'OpenSkills
OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.
Installation officielle d’OpenSkillsopenskills install './.skill-downloads/go-coding-conventions-mrwakdbn'openskills read 'go-coding-conventions-mrwakdbn'La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.
Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.
openskills syncMode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.
4. Faire un premier essai
Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :
Lis .skill-downloads/go-coding-conventions-mrwakdbn/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.
Bonnes pratiques React Hook Form
Developpement
Maîtrisez React Hook Form : évitez les anti-patterns, gérez les abonnements, et traitez correctement reset, dirty state et entrées contrôlées.
Migration Emotion vers Mantine
Developpement
Migrer les styled-components Emotion vers des composants Mantine avec style props et modules CSS. Pour convertir .styled.tsx ou supprimer les imports @emotion.
Détecteur de dérive de périmètre
Developpement
Analyse les diffs git par rapport à une intention pour détecter la dérive de périmètre, fichiers non liés et PR trop larges, puis suggère de garder, diviser ou justifier.