Thank you for your interest in contributing to codrao! Follow these guidelines to set up your environment, write tests, and submit changes.
- Go Version: Verify that you are running Go 1.24 or later:
go version
- Clone and Install Dependencies:
git clone https://github.com/SSOHEB/codrao.git cd codrao go mod download
We use a testing pyramid containing unit tests, golden tests, integration tests, and benchmarks. Ensure all tests pass before proposing modifications.
Verifies individual packages inside internal/ and cmd/:
make testAsserts that changes to generators do not cause unintended deviations in output files.
make test-goldenTo intentionally regenerate golden files after changing generator outputs:
go test ./tests/golden/... -updateDrives the CLI as a black box executing validate and generate subcommands on valid and invalid templates:
make test-integrationMeasures execution performance and memory allocations:
make benchTo ensure code quality before pushing, you can set up pre-commit hooks. We support two options:
Option 1: Using the pre-commit framework (Recommended) If you have pre-commit installed, run:
pre-commit installThis will configure hooks for go fmt, go vet, and golangci-lint to run automatically before every commit.
Option 2: Plain Git Hook If you don't use the pre-commit framework, you can use the provided fallback script:
cp scripts/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commitWe enforce strict Go formatting and lint checking. Run formatting and lint checks locally:
# Format source code
make fmt
# Run linters
golangci-lint run ./...- Doc Comments: Every exported constant, type, method, function, and variable must have a doc comment starting with its own name.
- Imports: Use
goimportsto sort and manage import blocks automatically. - Error Handling: Always check returned errors (e.g. do not ignore errors returned by
os.Setenvorf.Closeinside production or test files).