Cross-language coding standard (K22-CODE-01..26) adopted from Kingsrook's QQQ CODE_STYLE.md, with profiles for C#/.NET, Java, TypeScript, Python, Rust, Go, Swift, Shell/PowerShell, and Terraform, and the files each IDE and tool imports: IntelliJ scheme, copyright profile and live templates, Checkstyle, Eclipse formatter, .editorconfig, Directory.Build.props, ESLint Stylistic, ruff, rustfmt/clippy/cargo-deny, golangci-lint, swift-format/SwiftLint, ShellCheck, PSScriptAnalyzer, TFLint, sqlfluff, VS Code. Kingsrook files keep their Apache-2.0 notice (NOTICE). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Maes <james@kof22.com>
2.1 KiB
Go profile
The Kingsrook coding standard applied to Go. Requirement IDs are
K22-CODE-GO-NN. Configuration: configs/go/.
Tooling
| Concern | Tool | Version policy |
|---|---|---|
| Toolchain | Go (latest two releases supported upstream) | go and toolchain directives in go.mod |
| Formatter | gofmt + goimports (via golangci-lint fmt) |
toolchain |
| Linter | golangci-lint v2 with .golangci.yml |
pinned version in CI |
| Vulnerabilities | govulncheck |
latest |
| Tests | go test -race |
toolchain |
| Coverage | go test -coverprofile |
toolchain |
Requirements
K22-CODE-GO-01 (MUST) golangci-lint fmt --diff and golangci-lint run pass with
zero findings.
Verified by: CI.
K22-CODE-GO-02 (MUST) Deviation: layout is exactly gofmt's: tabs for indentation,
same-line braces, a space after if. gofmt is not configurable, the compiler's
semicolon insertion makes next-line braces a syntax error, and every Go tool assumes
gofmt output. K22-CODE-03 through K22-CODE-06 therefore do not apply to Go. Every
non-layout Kingsrook rule still applies.
K22-CODE-GO-03 (MUST) Header comments (K22-CODE-09) are Go doc comments starting
with the identifier's name, on every exported and unexported type and function; the
godot and revive exported rules enforce them for exported API.
K22-CODE-GO-04 (MUST) Logging uses log/slog with key/value attributes only
(sloglint kv-only); fmt.Print* and print are banned outside main CLI output
(forbidigo).
Verified by: golangci-lint.
K22-CODE-GO-05 (MUST) Errors are wrapped with context (fmt.Errorf("...: %w", err))
and compared with errors.Is/errors.As; gosec, errorlint, and wrapcheck pass.
govulncheck ./... reports no reachable vulnerabilities.
Verified by: CI. Maps to: OSPS-VM-05.03.
Commands
| Where | Command |
|---|---|
| Local fix | golangci-lint fmt && golangci-lint run --fix |
| CI | golangci-lint fmt --diff, golangci-lint run, go test -race -coverprofile=coverage.out ./..., govulncheck ./... |