Go Validation
This skill provides guidance for validating Go code using the comprehensive validation script.
When to Use This Skill
This skill is applicable for:
- •Validating Go code before committing
- •Running comprehensive quality checks
- •Ensuring test coverage meets standards
- •Security vulnerability scanning
Validation Script Usage
Always use the validation script. Do not run individual commands.
Usage
bash
# Full validation (recommended before commit) bash go-validation/scripts/validate.sh # Directory-specific validation (faster feedback during development) bash go-validation/scripts/validate.sh ./path/to/code/ # Auto-fix formatting issues bash go-validation/scripts/validate.sh --fix # With verbose output bash go-validation/scripts/validate.sh --verbose
What the Script Does
The validation script performs all checks in the correct order:
- •
go mod tidy- Clean up and verify dependencies - •
go fmt- Format Go code - •
go vet- Static analysis for suspicious constructs - •
golangci-lint- Comprehensive linting (30+ linters) - •
go test -v -race -cover- Run tests with race detection and coverage - •
govulncheck- Security vulnerability scanning
Validation Requirements
Before considering code complete:
- • All validation checks pass
- • Test coverage ≥ 80%
- • No test failures
- • No race conditions
- • No security vulnerabilities
Validation Workflow
- •Make changes - Implement feature or fix
- •Run validation:
bash go-validation/scripts/validate.sh ./path/to/code/ - •Fix issues - Address failures reported
- •Re-run validation - Ensure all checks pass
- •Commit - Only when validation passes
Reference Documentation
For detailed information:
- •Individual Commands - Command usage for debugging
- •Troubleshooting Guide - Error resolution
- •Testing Best Practices - Test patterns and coverage
- •Security Best Practices - Security guidelines