본문으로 건너뛰기
cccskills
무료GitHub에 공개

go

Idiomatic programming style, patterns, and conventions for Go (Golang) development. Trigger when: - Writing, refactoring, reviewing, or debugging Go code. - Files matching the pattern **/*.go (including go.mod, go.sum) are in the workspace or referenced. - Tasks involve: go fmt, go test, go build, go vet, golangci-lint. - Prompt contains keywords: go, golang, goroutine, channel, select, interface, err != nil, defer, panic, gofmt, struct.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md8.2 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Go Language Idioms

Go favors simplicity, readability, and explicit behavior. Work with the language's conventions, not against them.


Core Philosophy

  • Simplicity over cleverness — clear, boring code is better than clever, obscure code
  • Explicit over implicit — errors are values, not exceptions
  • Composition over inheritance — embed types, implement interfaces
  • Share by communicating — don't communicate by sharing memory

Formatting

Let gofmt handle it. Don't fight the formatter.

gofmt -w .        # Format all files
go fmt ./...      # Format package

All Go code in the ecosystem follows gofmt. There is no debate.


Naming

General Rules

ScopeStyleExample
ExportedPascalCaseReadFile, HTTPClient
UnexportedcamelCasereadFile, httpClient
Packageslowercase, single wordbytes, http, bufio
AcronymsAll capsHTTP, URL, ID (not Http, Url, Id)

Package Names

  • Short, concise, evocative
  • No underscores or mixedCaps
  • The package name is part of the type name: bufio.Reader, not bufio.BufReader

Getters and Setters

// ❌ Don't prefix getters with "Get"
func (u *User) GetName() string

// ✅ Just use the field name
func (u *User) Name() string

// ✅ Setters use "Set" prefix
func (u *User) SetName(name string)

Interface Names

One-method interfaces use method name + -er suffix:

MethodInterface
ReadReader
WriteWriter
CloseCloser
StringStringer

Functions

Multiple Return Values

Go functions return (result, error) instead of throwing:

func ReadFile(path string) ([]byte, error) {
    f, err := os.Open(path)
    if err != nil {
        return nil, err
    }
    defer f.Close()
    return io.ReadAll(f)
}

Named Return Values

Use for documentation, but avoid naked returns in non-trivial functions:

// Named returns document what's being returned
func ParseDuration(s string) (duration time.Duration, err error) {
    // ...
    return duration, nil  // Explicit, not naked
}

Defer

Use defer for cleanup. Defers execute LIFO at function exit:

func CopyFile(dst, src string) error {
    r, err := os.Open(src)
    if err != nil {
        return err
    }
    defer r.Close()

    w, err := os.Create(dst)
    if err != nil {
        return err
    }
    defer w.Close()

    _, err = io.Copy(w, r)
    return err
}

Interfaces

Keep Interfaces Small

Accept interfaces, return concrete types:

// ✅ Function accepts interface (flexible)
func Process(r io.Reader) error

// ✅ Function returns concrete type (useful)
func NewClient() *Client

Interface Satisfaction

Interfaces are satisfied implicitly—no implements keyword:

type Stringer interface {
    String() string
}

type User struct{ Name string }

// User satisfies Stringer automatically
func (u User) String() string {
    return u.Name
}

Compile-Time Check

Verify interface satisfaction at compile time:

var _ io.Reader = (*MyReader)(nil)

Pointers vs. Values

When to Use Pointer Receivers

Use PointerWhen
*TMethod modifies the receiver
*TStruct is large (avoid copying)
*TConsistency (if any method uses pointer, all should)

When to Use Value Receivers

Use ValueWhen
TMethod doesn't modify receiver
TType is small (int, small struct)
TType is immutable by design

Concurrency

Goroutines

Lightweight, start with go:

go func() {
    // runs concurrently
}()

Channels

Use channels for communication between goroutines:

ch := make(chan int)       // Unbuffered
ch := make(chan int, 100)  // Buffered

ch <- value   // Send
v := <-ch     // Receive

Share by Communicating

"Don't communicate by sharing memory; share memory by communicating."

// ❌ Shared state with mutex
var count int
var mu sync.Mutex

// ✅ Channel-based coordination
type result struct{ value int }
results := make(chan result)

Common Patterns

PatternUse Case
sync.WaitGroupWait for N goroutines to complete
context.ContextCancellation and timeouts
selectMultiplex channel operations
sync.OnceOne-time initialization

Error Handling

Errors Are Values

Check explicitly. Never discard with _:

// ❌ Never ignore errors
result, _ := doSomething()

// ✅ Always check
result, err := doSomething()
if err != nil {
    return fmt.Errorf("doing something: %w", err)
}

Error Wrapping

Use %w to wrap errors with context:

if err != nil {
    return fmt.Errorf("failed to parse config %s: %w", path, err)
}

Custom Errors

For libraries, define sentinel errors or custom types:

// Sentinel errors
var ErrNotFound = errors.New("not found")

// Custom error types
type ValidationError struct {
    Field   string
    Message string
}

func (e *ValidationError) Error() string {
    return fmt.Sprintf("%s: %s", e.Field, e.Message)
}

When to Panic

ContextPanic?Alternative
Library code❌ NeverReturn error
Impossible states✅ AcceptableAssert invariants
Init failures✅ Acceptablelog.Fatal

Anti-Patterns

Anti-PatternDescriptionRemedy
Ignoring errorsUsing _ to discard errorsAlways check or explicitly document why ignored
Naked returnsreturn without values in complex functionsUse explicit return values
Interface pollutionDefining interfaces before neededDefine interfaces at point of use
Premature channelsUsing channels when mutex sufficesStart simple; add concurrency primitives as needed
Giant interfacesInterfaces with many methodsKeep interfaces small; compose when needed

Tooling

go fmt ./...           # Format code
go vet ./...           # Static analysis
golangci-lint run      # Comprehensive linting
go test ./...          # Run tests
go test -race ./...    # Detect race conditions

Quick Reference

  • Errors are values — check explicitly, wrap with context
  • Accept interfaces, return structs — flexible inputs, concrete outputs
  • Use gofmt — no formatting debates
  • Prefer composition — embed types, small interfaces
  • Channels for coordination — share by communicating
  • defer for cleanup — runs at function exit, LIFO
  • No naked returns — be explicit in non-trivial functions

These idioms refine but are subordinate to the Code-Edit Constraints.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

ai-audit

무료

SOP for auditing AI-generated code. Trigger when: - Reviewing, refactoring, or cleaning up AI-generated code to prevent regressions or hallucinated APIs. - Prompt contains: /ai-audit, code audit, AI cleanup, common flaws.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

nrdxp/predicate102026년 9월 1일 업데이트

api-audit

무료

Protocol for auditing API surface coherence and type safety. Trigger when: - Evaluating API designs, interface type safety, or design elegance. - Prompt contains: /api-audit, API surface, API coherence, type safety.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

nrdxp/predicate102026년 9월 1일 업데이트

boundary

무료

Normative sufficiency conditions for Initial Boundary Conditions (IBCs) and the SOP for the cheap-tier boundary refinement loop (/boundary). Trigger when: - Crafting, auditing, or refining a prompt/IBC destined for an expensive (architect-class) model or an autonomous worker dispatch. - Evaluating whether a task frame is sufficient to bound an agent walk. - Prompt contains: /boundary, IBC, initial boundary condition, boundary contract, sufficiency conditions, worker prompt, prompt refinement.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

nrdxp/predicate102026년 9월 1일 업데이트

campaign

무료

SOP for the architect-tier campaign workflow (/campaign): exhaustive survey, mitigation planning, tiered orchestration, and reconciliation. Trigger when: - Running a multi-workstream initiative where an expensive architect-tier council surveys, plans, emits worker prompts, and judges landed work. - Conducting production-readiness assessments that fan out into autonomous mitigation dispatches across model tiers. - Prompt contains: /campaign, campaign workflow, survey, orchestrate, reconcile, premise freshness, tier routing, worker IBC, scratch.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

nrdxp/predicate102026년 9월 1일 업데이트

chronicle

무료

Maintain and update the persistent project chronicle (docs/chronicle.md). Trigger when: - The human requests a history summary or chronicle update. - Starting work on a new codebase and needing context on its evolution. - Prompt contains keywords: /chronicle, chronicle, project history, git log summary, history summary.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

nrdxp/predicate102026년 9월 1일 업데이트

Rules, conventions, and constraints for formatting git commit messages and committing at logical boundaries. Trigger when: - Drafting, revising, or validating git commit messages. - Pausing at commit boundaries under the CORE or CONTINUE workflows. - Evaluating whether a changeset should be split into multiple commits. - Prompt contains keywords: commit message, git commit, conventional commits, commit hygiene, commit guidelines, logical boundary, spaghetti diff, atomic commit, commit boundary.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

nrdxp/predicate102026년 9월 1일 업데이트

nrdxp의 스킬 모두 보기

이 스킬의 문제 신고