go-rules
Go conventions for this project. Use when reading, writing, or reviewing files matching `**/*.go`, `**/go.mod`. Do not use for other files.
SKILL.mdplugins/agent-kit/skills/go-rules/SKILL.md
GitHubGo conventions
- Match the project's Go version in
go.mod, its module layout, and its linters (golangci-lintconfiguration if present). Keep codegofmt-formatted andgo vetclean. - Return errors instead of panicking; wrap them with context using
fmt.Errorf("...: %w", err)and check them witherrors.Isanderrors.As. Never ignore a returned error without a comment saying why. - Pass
context.Contextas the first parameter of functions that do I/O or may block, and respect cancellation. Do not store contexts in structs. - Every goroutine needs a way to stop (context cancellation, a closed channel, or a
sync.WaitGroupthe caller waits on). Protect shared state with a mutex or confine it to one goroutine. deferclosing of files, response bodies, and rows right after the error check, and unlocking right after locking. For files you write, check the error fromClose.- Prefer the standard library and the project's existing dependencies. Do not add modules without saying so.
- Run
go build ./...,go vet ./..., andgo test ./...(with-racewhere the project uses it) after changes.