mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-12-17 04:36:17 +01:00
1.7 KiB
1.7 KiB
ClusterCockpit Backend - Agent Guidelines
Build/Test Commands
- Build:
makeorgo build ./cmd/cc-backend - Run all tests:
make test(runs:go clean -testcache && go build ./... && go vet ./... && go test ./...) - Run single test:
go test -run TestName ./path/to/package - Run single test file:
go test ./path/to/package -run TestName - Frontend build:
cd web/frontend && npm install && npm run build - Generate GraphQL:
make graphql(uses gqlgen) - Generate Swagger:
make swagger(uses swaggo/swag)
Code Style
- Formatting: Use
gofumptfor all Go files (strict requirement) - Copyright header: All files must include copyright header (see existing files)
- Package docs: Document packages with comprehensive package-level comments explaining purpose, usage, configuration
- Imports: Standard library first, then external packages, then internal packages (grouped with blank lines)
- Naming: Use camelCase for private, PascalCase for exported; descriptive names (e.g.,
JobRepository,handleError) - Error handling: Return errors, don't panic; use custom error types where appropriate; log with cclog package
- Logging: Use
cclogpackage (e.g.,cclog.Errorf(),cclog.Warnf(),cclog.Debugf()) - Testing: Use standard
testingpackage; usetestify/assertfor assertions; name testsTestFunctionName - Comments: Document all exported functions/types with godoc-style comments
- Structs: Document fields with inline comments, especially for complex configurations
- HTTP handlers: Return proper status codes; use
handleError()helper for consistent error responses - JSON: Use struct tags for JSON marshaling;
DisallowUnknownFields()for strict decoding