A CLI tool for generating CloudWeGo-based microservice projects using Hertz (HTTP framework) and Kitex (RPC framework).
- Generates CloudWeGo microservice projects with Hertz and Kitex
- Uses sweets-layout as the project template
- Supports custom module names
- Automatically installs dependencies
- Includes Wire dependency injection setup
- GORM for database operations with Goose migrations
- Protobuf validation support
# Clone the cli repository
git clone https://github.com/go-sweets/cli
cd cli
# Build the CLI tool
go build -o swe-cli main.go
# Install globally (optional)
cp swe-cli /usr/local/bin/go install github.com/go-sweets/cli@latest# Generate project with default module name
swe-cli new helloservice
# Generate project with custom module name
swe-cli new helloservice github.com/myorg/helloservicehelloservice/
├── api/ # Protocol buffer definitions
├── cmd/ # Application entry points
├── internal/ # Internal application code
│ ├── boundedcontexts/ # DDD bounded contexts
│ ├── config/ # Configuration
│ ├── server/ # HTTP and gRPC servers
│ └── service/ # Service implementations
├── etc/ # Configuration files
├── Makefile # Build and development commands
└── go.mod # Go module definition
cd helloservice
make init # Install tools and dependencies
make api # Generate protobuf code
make gen # Generate Wire dependency injection
make run # Run the serviceswe-cli new <project-name> [module-name]- Generate a new CloudWeGo microservice projectswe-cli version- Show CLI versionswe-cli help- Show help information
- Go 1.21 or later
- Access to go-sweets repository (for template)
The generated project includes:
- HTTP Server: CloudWeGo Hertz with middleware support
- RPC Server: CloudWeGo Kitex with interceptors
- Database: GORM with MySQL driver and Goose migrations
- Caching: Redis integration
- Dependency Injection: Google Wire
- Configuration: Viper-based configuration management
- Validation: Protobuf validation with protoc-gen-validate
- Monitoring: Prometheus metrics and tracing support
Apache License Version 2.0, http://www.apache.org/licenses/