Skip to main content

go-best-practices

Production Go patterns — lifecycle, concurrency, config, testing, CI. Use when writing, reviewing, or refactoring Go code. Triggers on Go code review, Go refactoring, or 'go best practices'.

설치로 이동

소스 정보

저장소
poteto/noodle
최근 소스 활동
2026년 3월 19일 04:43
감지된 SKILL.md 언어
영어
스타
281
포크
16

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

파일 탐색기
2 개 파일

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
go-best-practices
description
Production Go patterns — lifecycle, concurrency, config, testing, CI. Use when writing, reviewing, or refactoring Go code. Triggers on Go code review, Go refactoring, or 'go best practices'.
# Go Best Practices | Pattern | When to apply | |---------|---------------| | Minimal main | New binaries | | Single bootstrap | App wiring across modes | | Ordered shutdown | Long-running processes | | Non-blocking fanout | Channel-based event systems | | Concurrency testing | Any goroutine code | | Layered config | Multi-source configuration | | Cross-platform paths | File/config path resolution | | Secure debug logging | HTTP client instrumentation | | Golden test matrices | Rendering / output components | | Focused linters | CI pipeline setup | Read [references/patterns.md](references/patterns.md) for code examples. ## Rules 1. **main.go is a stub.** Call `cmd.Execute()` and nothing else. Gate diagnostics (pprof) behind env vars. 2. **One bootstrap path.** All modes (interactive, headless, test) share the same initialization function. Two paths will drift. 3. **Ordered shutdown.** Cancel dependents before their dependencies, then run independent cleanup in parallel under a timeout context. WaitGroup the parallel phase. 4. **Never block the sender.** Non-blocking channel sends with an explicit drop policy. Log drops at debug level. Document the policy. 5. **Test concurrency mechanically.** `testing/synctest` for deterministic timing, `goleak.VerifyNone` for leak detection, dedicated regression tests for timer/channel deadlocks. 6. **Explicit config precedence.** Global → project → flags. Walk up from CWD to discover project configs, reverse so closest wins, deep-merge. 7. **Centralize platform paths.** One function per concern. Resolution order: env override → XDG → platform default → fallback. 8. **Redact secrets in debug logs.** Wrap `http.RoundTripper`. Filter headers matching authorization, api-key, token, secret. Gate on debug level to skip allocation in prod. 9. **Golden tests over matrices.** Cross dimensions (layout × theme × size) as parallel subtests. Sweep continuous ranges to catch off-by-one bugs. 10. **Focused linters, not all linters.** Enable what catches real bugs (bodyclose, noctx, tparallel). Disable noisy defaults. Add project-specific checks as scripts. Always `-race` in tests.
GitHub에서 보기