- Added comprehensive bounds checking to prevent buffer overruns in multicall parsing - Implemented graduated validation system (Strict/Moderate/Permissive) to reduce false positives - Added LRU caching system for address validation with 10-minute TTL - Enhanced ABI decoder with missing Universal Router and Arbitrum-specific DEX signatures - Fixed duplicate function declarations and import conflicts across multiple files - Added error recovery mechanisms with multiple fallback strategies - Updated tests to handle new validation behavior for suspicious addresses - Fixed parser test expectations for improved validation system - Applied gofmt formatting fixes to ensure code style compliance - Fixed mutex copying issues in monitoring package by introducing MetricsSnapshot - Resolved critical security vulnerabilities in heuristic address extraction - Progress: Updated TODO audit from 10% to 35% complete 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
5.0 KiB
5.0 KiB
Reusable, Agnostic Go Project Template
This template provides a complete project structure and tooling that can be reused across different Go projects.
Template Structure
project-name/
├── Makefile # Main project build and test commands
├── .env.example # Environment variables template
├── .gitignore # Git ignore patterns
├── README.md # Project documentation
├── go.mod, go.sum # Go module files
├── scripts/ # Reusable scripts
│ ├── build.sh # Universal build script
│ ├── test-runner.sh # Universal test runner
│ ├── setup-dev.sh # Development environment setup
│ ├── performance-profile.sh # Performance profiling
│ └── ci-*.sh # CI/CD scripts
├── cmd/ # Main applications
│ └── app-name/ # Main application entry point
├── internal/ # Internal application code
│ ├── config/ # Configuration management
│ ├── logger/ # Logging utilities
│ └── ... # Other internal packages
├── pkg/ # Exportable libraries
│ ├── module-a/ # Reusable component
│ └── module-b/ # Reusable component
├── test/ # Test suites
│ ├── unit/ # Unit tests
│ ├── integration/ # Integration tests
│ ├── e2e/ # End-to-end tests
│ ├── property/ # Property-based tests
│ ├── fuzzing/ # Fuzzing tests
│ ├── security/ # Security tests
│ └── stress/ # Stress tests
├── docs/ # Documentation
│ ├── api/ # API documentation
│ └── development/ # Development guides
├── reports/ # Generated reports
│ ├── coverage/ # Coverage reports
│ ├── test-results/ # Test execution results
│ └── performance/ # Performance reports
├── storage/ # Persistent storage
│ └── keystore/ # Key storage (if applicable)
└── tools/ # Development tools
├── math-audit/ # Mathematical validation tools
└── security-scanner/ # Security validation tools
Universal Makefile Commands
The template includes a comprehensive set of Make commands at different levels:
Basic Commands
make build- Build the applicationmake run- Run the applicationmake test- Run testsmake clean- Clean build artifacts
Testing Commands (Multi-Level)
make test-basic- Run basic tests (fast)make test-unit- Run unit testsmake test-integration- Run integration testsmake test-e2e- Run end-to-end testsmake test-comprehensive- Run comprehensive testsmake test-audit- Run full audit testsmake test-coverage- Run tests with coverage
Development Commands
make dev-setup- Setup development environmentmake dev-workflow- Run development workflowmake watch-tests- Watch and run tests on file changesmake debug- Run application in debug mode
Audit Commands
make audit-full- Run comprehensive auditmake audit-security- Run security auditmake audit-performance- Run performance auditmake audit-quality- Run code quality auditmake audit-deps- Run dependency audit
CI/CD Commands
make ci-precommit- Fast pre-commit validationmake ci-quick- Quick CI pipelinemake ci-dev- Development CI pipelinemake ci-full- Full CI pipeline
Reusable Scripts
The template includes several universal scripts:
build.sh
A configurable build script that works with any Go project:
# Build with default settings
./scripts/build.sh
# Build with custom settings
BINARY_NAME=myapp OUTPUT=dist/myapp ./scripts/build.sh
test-runner.sh
A configurable test runner that works with different test levels:
# Run basic tests
TEST_LEVEL=basic ./scripts/test-runner.sh
# Run audit tests with coverage
TEST_LEVEL=audit COVERAGE=true ./scripts/test-runner.sh
setup-dev.sh
A development environment setup script that handles dependencies and configuration.
Benefits
- Consistency: All projects use the same structure and commands
- Maintainability: Common scripts and make targets are easier to maintain
- Productivity: Developers can quickly understand and work with new projects
- Extensibility: Easy to add new commands or modify existing ones
- Reusability: Components can be shared across projects
Usage
- Copy this template structure to your new project
- Update the configuration variables in Makefile and scripts
- Customize the module name in go.mod
- Adjust the main application in cmd/ directory
- Add your specific packages to pkg/ and internal/ directories
- Add your tests to the test/ directory according to type