spf13-go
Review Go library APIs, package boundaries, tests, iterators and standard-library choices. Load for broad design or idiom reviews after the repository-owned Go skills.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- spf13-go
- description
- Review Go library APIs, package boundaries, tests, iterators and standard-library choices. Load for broad design or idiom reviews after the repository-owned Go skills.
02 资源文件 3
- 许可证LICENSE1.0 KB
- 参考文档references/go.md26.4 KB
- 参考文档UPSTREAM.md1.7 KB
03 SKILL.md 正文
Third-party guidance. Repository rules
.cratis/ai/rules/go.mdandgo-cratis-parity.mdtake precedence where they conflict (e.g. Go minimum version from go.mod, nopkg/, functional options only when warranted).
Idiomatic Go: local entry point
Read the qualifications below, then load the relevant sections of the pinned upstream guide. The long original skill body is kept as a reference so discovery does not load the entire guide automatically.
Local review qualifications
These qualifications override the corresponding upstream prescriptions:
- Package depth, flat layout and a three-type threshold for generics are
heuristics, not Go rules. Use
internal/for implementation-only packages; its import restriction is based on the parent directory tree, not simply module identity. An application's non-main packages can be imported unless protected. - Preserve Cratis extension interfaces and typed generic APIs when the contract needs them. Do not reject an API merely because it resembles another language.
- A stateful domain entry point does not mandate reloading on every method call. Absence of globals alone does not make an object safe for concurrent use.
- Per-iteration capture applies to Go 1.22+ loop variables declared with
:=, not pre-existing variables assigned with=. ValidatemaxConcurrent > 0;errgroup.SetLimitadmission can block and is not context-cancelable. - Mutexes, bounded workers and semaphores are valid choices; channels and errgroup are not universally preferable. All goroutines need ownership and joining.
- Explicit stream handles/Next methods are valid for I/O, terminal errors, acknowledgments and Close ownership. Iterators must honor early stop and cleanup.
cmp.Orneeds Go 1.22, not 1.21; it eagerly evaluates all arguments and treats zero as absent. Multiple%woperands are supported since Go 1.20;errors.Joinis a choice, not a universal replacement. Wrap only intended public identities.- Filesystem abstraction/Afero, go-cmp and table-driven tests are optional.
Standard-library interfaces and
t.TempDiroften suffice; do not add dependencies merely because upstream calls one an industry standard. T.Contextis canceled before cleanup callbacks run.testing/synctestdoes not make real networking deterministic. Test resource cleanup explicitly.WithoutCancelalso drops deadlines. Never detach caller-owned SDK operations; explicitly independent work needs its own budget, owner, stop and join path.- HTTP timeout examples are illustrative, not streaming defaults. Shutdown does not cancel active request contexts automatically or close hijacked WebSockets; explicitly signal long-lived handlers, close/join owned connections, handle shutdown failure, and join the serving goroutine. A handler context deadline cannot forcibly stop a handler that ignores it.
- Use an injected logger and context-aware methods; the upstream
slog.Withexample actually derives from the global logger, not from context. - Use
crypto/randfor security, not either math/rand package. Preserve established JSON tags and presence semantics rather than addingomitzeromechanically. - Version-gate every modern feature. Existing older-version build tags/tool tracking may need preservation. Never change the baseline to satisfy this guide.
- Go build/run can reuse valid cached compilation, and test results may be cached. Inspect inputs, build constraints and test-cache behavior before diagnosing; do not treat the toolchain as infallible or clear caches without evidence.
04 同仓库更多 Skills
samber-golang-error-handling
Review Go error creation, wrapping, inspection and logging boundaries. Load when changing caller-visible failures after go-errors-and-context.
samber-golang-context
Design Go context propagation, cancellation, deadlines and request metadata. Load for operation-lifetime changes or context-related leaks after go-errors-and-context.
jetbrains-go-modern-guidelines
Choose version-compatible modern Go syntax and standard-library APIs. Load when modernizing touched Go code after reading go.mod and build constraints.
go-testing
Write and review Go unit, contract, transport, race, fuzz, and deterministic concurrency tests. Use for new behavior, bug fixes, flaky tests, and public API parity evidence.
go-release-modules
Review Go module dependencies, minimum versions, compatibility, semantic labels, release-action tags, and proxy discoverability. Use for release preparation, retractions, and major-version migration planning.
go-library-api-design
Design or review exported Go APIs, constructors, interfaces, generics, iteration, ownership, and compatibility. Use when adding or changing public Go library surface.