A powerful command-line interface tool for quickly scaffolding and setting up Go web applications using the Gin framework.
- 🚀 Quick project scaffolding with clean architecture
- 📦 Database setup (PostgreSQL and MongoDB)
- 🔄 CRUD operation generation
- 🛠️ Service layer generation
- 📝 Environment configuration management
- 🏗️ Standardized project structure
go install github.com/mauwia/gin-cli@latest
gin-cli new my-project
This will create a new project with the following structure:
my-project/
├── config/ # Configuration management
├── internal/ # Private application code
│ ├── server/ # Server setup and routing
│ ├── controllers/ # HTTP request handlers
│ ├── models/ # Data structures
│ ├── services/ # Business logic
│ ├── repositories/# Data access layer
│ ├── middlewares/ # HTTP middleware
│ └── utils/ # Utility functions
├── migrations/ # Database migrations
└── .env # Environment configuration
gin-cli setup postgres
This will:
- Install required dependencies (gorm.io/gorm, gorm.io/driver/postgres)
- Configure environment variables
- Set up database configuration
- Initialize database connection
gin-cli setup mongodb
This will:
- Install required dependencies (go.mongodb.org/mongo-driver/mongo)
- Configure environment variables
- Set up MongoDB configuration
- Initialize database connection
gin-cli generate crud user
This will generate:
- Controller
- Service
- Repository
- Model for the specified entity (in this case, "user")
gin-cli generate service auth
This will generate a new service file for the specified service name.
gin-cli update env
Updates the environment configuration based on your .env file.
The generated project follows clean architecture principles:
- Controllers: Handle HTTP requests and responses
- Services: Contain business logic
- Repositories: Handle data access
- Models: Define data structures
- Middlewares: Handle cross-cutting concerns
- Utils: Contains utility functions
Default environment variables:
DB_USER=postgres
DB_PASSWORD=password
DB_NAME=postgres
DB_PORT=5432
DB_HOST=localhost
Default environment variables:
MONGODB_URI=
MONGODB_DATABASE=
- Go 1.x or higher
- Git
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.