Files
mev-beta/orig/.qwen/templates/GO_PROJECT_TEMPLATE.md
Administrator c54c569f30 refactor: move all remaining files to orig/ directory
Completed clean root directory structure:
- Root now contains only: .git, .env, docs/, orig/
- Moved all remaining files and directories to orig/:
  - Config files (.claude, .dockerignore, .drone.yml, etc.)
  - All .env variants (except active .env)
  - Git config (.gitconfig, .github, .gitignore, etc.)
  - Tool configs (.golangci.yml, .revive.toml, etc.)
  - Documentation (*.md files, @prompts)
  - Build files (Dockerfiles, Makefile, go.mod, go.sum)
  - Docker compose files
  - All source directories (scripts, tests, tools, etc.)
  - Runtime directories (logs, monitoring, reports)
  - Dependency files (node_modules, lib, cache)
  - Special files (--delete)

- Removed empty runtime directories (bin/, data/)

V2 structure is now clean:
- docs/planning/ - V2 planning documents
- orig/ - Complete V1 codebase preserved
- .env - Active environment config (not in git)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 10:53:05 +01:00

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 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:

# 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

  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