Implement or audit idiomatic Go code using effective naming, errors, context, interfaces, generics, nil handling, slices/maps, documentation comments, and standard library conventions. Use when writing, refactoring, cleaning, or reviewing Golang code; reducing nesting; improving API ergonomics; checking idiomatic implementation style; or finding non-idiomatic Go in existing code.
التثبيت
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
Implement or audit idiomatic Go code using effective naming, errors, context, interfaces, generics, nil handling, slices/maps, documentation comments, and standard library conventions. Use when writing, refactoring, cleaning, or reviewing Golang code; reducing nesting; improving API ergonomics; checking idiomatic implementation style; or finding non-idiomatic Go in existing code.
Go Implementation Idioms
Build Workflow
Prefer straightforward code over abstraction. Make the happy path read down the page by handling errors early.
Use the standard library idioms already present in the repo: context, errors, fmt, io, testing, slog, net/http, and so on.
Keep names short but explanatory at their scope. Avoid package-name stutter in exported identifiers.
Wrap errors with context using %w when callers need errors.Is or errors.As.
Accept small interfaces and return concrete types. Avoid pointers to interfaces.
Use type parameters for real type relationships; do not use generics to avoid writing clear domain code.
Treat nil carefully: nil slices are usually fine for empty collections; maps must be made before writes.
Document exported packages, types, functions, methods, and non-obvious behavior for users.
Run gofmt/goimports after edits and keep generated code separate.
Audit Workflow
Inspect call sites before judging names, exported APIs, interfaces, or generic types.
Flag error handling that loses classification, context, wrapping, cancellation, or caller actionability.