Base agent rules live in the Helix Constitution — READ IT FIRST. This module is a submodule of a project that includes the Helix Constitution submodule. All rules in
constitution/AGENTS.mdand theconstitution/Constitution.mdit references apply unconditionally. Locate the constitution submodule from any arbitrary nested depth using itsfind_constitution.shhelper.
Canonical reference: https://github.com/HelixDevelopment/HelixConstitution
# Standard build
go build -o htCore main.go
# Full build with verification (recommended)
./scripts/build.sh
# Release build
./scripts/build.sh --release# All tests
go test ./...
# With race detection
go test -race ./...
# With coverage
go test -cover ./...
# Single package
go test ./internal/models/
# Single test function
go test -run TestRequest_IsAuthenticationRequired ./internal/models/
# Comprehensive verification (recommended)
./scripts/verify-tests.sh# Check for issues
go vet ./...
# Format code
go fmt ./...
# Check formatting
gofmt -l .- Follow Go standard formatting (
gofmt) - Use
go vetfor static analysis - Interface-based design for testability
- Comprehensive error handling with proper error types
- Use structured logging with zap
- Table-driven tests with testify/assert
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"helixtrack.ru/core/internal/models"
)- Standard library first
- Third-party packages second
- Local packages last
- Blank line between groups
- Exported: PascalCase (functions, types, constants)
- Unexported: camelCase (functions, variables)
- Constants: PascalCase for exported, camelCase for unexported
- Files: snake_case.go
- Test files: *_test.go
// Exported function with documentation
// DoSomething performs an important operation
func DoSomething(ctx context.Context, input string) (output string, err error) {
// Implementation
}
// Unexported helper function
func doHelper(input string) string {
// Implementation
}// Proper error handling with context
func processRequest(ctx context.Context) error {
result, err := someOperation(ctx)
if err != nil {
logger.Errorf("Failed to process: %v", err)
return fmt.Errorf("processing failed: %w", err)
}
return nil
}func TestFunction(t *testing.T) {
tests := []struct {
name string
input string
expected string
wantErr bool
}{
{
name: "success case",
input: "test",
expected: "result",
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result, err := functionUnderTest(tt.input)
if tt.wantErr {
assert.Error(t, err)
} else {
assert.NoError(t, err)
assert.Equal(t, tt.expected, result)
}
})
}
}// Exported struct
type Handler struct {
db database.Database
authService services.AuthService
version string
}
// Constructor
func NewHandler(db database.Database, authService services.AuthService, version string) *Handler {
return &Handler{
db: db,
authService: authService,
version: version,
}
}const (
// Exported constants
ActionCreate = "create"
ActionModify = "modify"
// Group related constants together
defaultTimeout = 30 * time.Second
maxRetries = 3
)func operation(ctx context.Context) error {
// Use context for cancellation
select {
case <-ctx.Done():
return ctx.Err()
default:
// Continue operation
}
return nil
}// Structured logging
logger.Infof("Starting operation: %s", operationName)
logger.Errorf("Operation failed: %v", err)
logger.Debugw("Debug info", "key", value, "another", value2)
```</content>
</xai:function_call</xai:function_call