Language & Logic
- •Context: NEVER use
context.Contextto pass logic-influencing Values (WithValue). - •Timeouts: NO hidden timeouts; all timeouts MUST be handled via
context.Context. - •Branching: Use
switchinstead of chainedifstatements for >2 semantic branches. - •Workspace: Prefer editing
go.workovergo.mod. - •Linter: Adhere to all linter rules (e.g.,
rangeint). Satisfaction of the linter is mandatory. - •Logging: NO
fmt.Print*for logs. Useloggerpackage with appropriate levels. UseTracefor frequency >1/sec. - •Errors: Favor custom non-pointer error types over wrapping (
errors.Wrap,fmt.Errorf) where feasible.
Testing Protocols
- •Timeout:
go testtimeout must NEVER exceed 4 minutes. - •Location:
- •Unit:
<filename>_test.gonext to source. - •Integration:
<filename>_integration_test.goat highest-level tested code. - •System/E2E:
tests/e2e/ortests/system/.
- •Unit:
- •Naming:
Test<FunctionOrFeature><WhatIsBeingTested>. - •Mocks: Use mocks for external communications in unit and internal integration tests.
- •Build Tags: Use
test_integrationfor external integration andtest_e2efor E2E tests.
Files & Errors
- •Specificity: File names must be specific. Group short files only if semantically very close.
- •Error Registry: Always keep all error types in
errors.go.