- 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>
131 lines
5.0 KiB
Markdown
131 lines
5.0 KiB
Markdown
# 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 application
|
|
- `make run` - Run the application
|
|
- `make test` - Run tests
|
|
- `make clean` - Clean build artifacts
|
|
|
|
### Testing Commands (Multi-Level)
|
|
- `make test-basic` - Run basic tests (fast)
|
|
- `make test-unit` - Run unit tests
|
|
- `make test-integration` - Run integration tests
|
|
- `make test-e2e` - Run end-to-end tests
|
|
- `make test-comprehensive` - Run comprehensive tests
|
|
- `make test-audit` - Run full audit tests
|
|
- `make test-coverage` - Run tests with coverage
|
|
|
|
### Development Commands
|
|
- `make dev-setup` - Setup development environment
|
|
- `make dev-workflow` - Run development workflow
|
|
- `make watch-tests` - Watch and run tests on file changes
|
|
- `make debug` - Run application in debug mode
|
|
|
|
### Audit Commands
|
|
- `make audit-full` - Run comprehensive audit
|
|
- `make audit-security` - Run security audit
|
|
- `make audit-performance` - Run performance audit
|
|
- `make audit-quality` - Run code quality audit
|
|
- `make audit-deps` - Run dependency audit
|
|
|
|
### CI/CD Commands
|
|
- `make ci-precommit` - Fast pre-commit validation
|
|
- `make ci-quick` - Quick CI pipeline
|
|
- `make ci-dev` - Development CI pipeline
|
|
- `make 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:
|
|
```bash
|
|
# 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:
|
|
```bash
|
|
# 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
|
|
|
|
1. **Consistency**: All projects use the same structure and commands
|
|
2. **Maintainability**: Common scripts and make targets are easier to maintain
|
|
3. **Productivity**: Developers can quickly understand and work with new projects
|
|
4. **Extensibility**: Easy to add new commands or modify existing ones
|
|
5. **Reusability**: Components can be shared across projects
|
|
|
|
## Usage
|
|
|
|
1. Copy this template structure to your new project
|
|
2. Update the configuration variables in Makefile and scripts
|
|
3. Customize the module name in go.mod
|
|
4. Adjust the main application in cmd/ directory
|
|
5. Add your specific packages to pkg/ and internal/ directories
|
|
6. Add your tests to the test/ directory according to type |