kroot

Coding Standards — Kroot

Normative rules for code in this repository. AGENTS.md states the principles; this document states the specifics.

Go

Formatting and analysis

Enforced, in order, by make ci:

Gate Tool Command
Format gofmt, gofumpt, goimports make fmt-check
Static analysis go vet make vet
Lint golangci-lint (pinned v2) make lint

A lint suppression must be specific and explained:

//nolint:gosec // G404: this PRNG seeds a load-balancing shuffle, not a secret.

Blanket suppressions, or suppressions without a reason, fail the nolintlint check.

Errors

Interfaces and types

Concurrency

Naming

Kind Convention Example
Package short, lower-case, no underscores envconfig
Exported identifier PascalCase, doc comment required Server, NewServer
Unexported identifier camelCase parseFlags
Acronym all caps inside the name HTTPServer, UserID
Test file <file>_test.go main_test.go
Test helper package internal/testutil (test-only, depguard-enforced)  

Package layout

Path Purpose
internal/ private code; not importable from outside the module
cmd/<binary>/ one directory per binary when there is more than one
pkg/ code deliberately offered for reuse (optional, rare)
testdata/ fixtures; ignored by the Go toolchain
web/ frontend workspace, added when the UI milestone lands

main packages contain wiring only: parse flags, read configuration, construct dependencies, hand off, handle shutdown. Logic lives in importable packages so it can be tested without spawning a process.

Dependencies

TypeScript (web/, when it lands)

Documentation