A command-line tool to quickly generate Go projects using clean architecture principles.
- 🚀 Generate Project: Creates a complete Go project structure based on clean architecture
- 📦 Generate Domain: Adds new domain modules to your existing project
go install github.com/dung13890/go-base-gen@latestgo-base-gen project --pkg github.com/yourusername/yourproject --path yourprojectParameters:
--pkg: Your project's Go module path (required)--path: Directory where the project will be created (optional, defaults to current directory)
cd yourproject
go mod tidy # Download dependencies
cp .env.example .env # Create environment configuration
go run cmd/migrate/main.go # Set up databasego-base-gen domain --dn product --pkg github.com/yourusername/yourprojectParameters:
--dn: Domain name (e.g., user, product, order)--pkg: Your project's Go module path (same as project creation)--path: Project directory (optional)
make dev# Step 1: Generate project
go-base-gen project --pkg github.com/johndoe/shopapi --path shopapi
# Step 2: Navigate to project
cd shopapi
# Step 3: Install dependencies
go mod tidy
# Step 4: Configure environment
cp .env.example .env
# Edit .env with your database credentials
# Step 5: Initialize database
go run cmd/migrate/main.go
# Step 6: Create domains
go-base-gen domain --dn product --pkg github.com/johndoe/shopapi
go-base-gen domain --dn customer --pkg github.com/johndoe/shopapi
# Step 7: Start development server
make dev# Show help
go-base-gen --help
# Generate project
go-base-gen project --pkg <module-path> [--path <directory>]
# Generate domain
go-base-gen domain --dn <domain-name> --pkg <module-path> [--path <directory>]
# Show version
go-base-gen --versionAfter generation, your project will follow clean architecture with:
- API Layer: HTTP handlers and routing
- Use Cases: Business logic
- Repositories: Data access layer
- Entities: Domain models
Learn more about the architecture in the go-clean-architecture repository.
If you find this tool helpful, consider:
MIT License - see LICENSE for details.
