- Test all:
go test ./... -race - Test package:
go test ./mcp -vorgo test ./server -v - Test single:
go test -run TestName ./package -v - Coverage:
go test -coverprofile=coverage.txt -covermode=atomic $(go list ./... | grep -v '/examples/' | grep -v '/testdata' | grep -v '/mcptest' | grep -v '/server/internal/gen') - Lint:
golangci-lint run(uses .golangci.yml config) - Generate:
go generate ./...(regenerates hooks and request handlers)
- Verified commits: When possible, make verified (signed) commits using GPG, SSH, or S/MIME signing keys
- Imports: Standard library first, then third-party, then local packages (goimports handles this)
- Naming: Use Go conventions - exported names (PascalCase), unexported names (camelCase), acronyms uppercase (HTTP, JSON, MCP)
- Error handling: Return sentinel errors (e.g.,
ErrMethodNotFound), wrap withfmt.Errorf("context: %w", err), useerrors.Is/Asfor checking - Types: Use explicit types; avoid
anyexcept for protocol flexibility (e.g.,Arguments any); prefer strongly-typed structs - Comments: All exported types/functions MUST have godoc comments starting with the name; no inline comments unless necessary
- Testing: Use
testify/assertandtestify/require; table-driven tests withtests := []struct{ name, ... }; test files end in_test.go - Context: Always accept
context.Contextas first parameter in handlers and long-running functions - Thread safety: Use
sync.Mutexfor shared state; document thread-safety requirements in comments - JSON: Use json tags with
omitemptyfor optional fields; usejson.RawMessagefor flexible/deferred parsing