A powerful CLI tool to generate complete CRUD resources for Go Fiber framework in seconds β‘
Stop writing repetitive boilerplate code! Gogen generates production-ready CRUD APIs with models, controllers, services, repositories, and routesβall in one command.
- π― One Command Generation - Generate complete CRUD structure instantly
- π Clean Architecture - Follows best practices with separated concerns
A command-line tool for generating CRUD resource scaffolding for the Go Fiber web framework. gogen automates the creation of controllers, services, repositories, and routes, following clean architecture principles.
- Generates complete CRUD resource structure for Go Fiber
- Produces controller, service, repository, and route files
- Supports custom output directory
- Minimal dependencies, fast execution
- Clean, idiomatic Go code structure
go install github.com/zaheershaikh936/gogen@latestEnsure that your $GOPATH/bin is in your PATH.
- Visit Releases
- Download the binary for your OS (Windows, Linux, macOS)
- Add the binary location to your
PATH
gogen resource <model> [flags]<model>: Required. The singular name of the resource to generate (e.g.,user,product). The tool will pluralize as needed for folder and file names.
| Flag | Short | Default | Description |
|---|---|---|---|
--output |
-o |
./ |
Output directory for generated files |
--help |
-h |
Show help for the command |
- The tool creates a new folder for the resource under the specified output directory.
- Existing files with the same name will be overwritten.
- Only one resource can be generated per command invocation.
Generate a user resource in the current directory:
gogen resource userGenerate a product resource in a custom directory:
gogen resource product --output ./apiUse the short flag for output directory:
gogen resource order -o ./srcShow help for the resource command:
gogen resource --helpCommand:
gogen resource invoice --output ./internal/apiGenerated folder structure:
internal/api/invoice/
βββ controllers/
β βββ invoice_controller.go
βββ services/
β βββ invoice_service.go
βββ repositories/
β βββ invoice_repository.go
βββ routes/
βββ invoice_routes.go
π Generating CRUD resource...
invoice :Model
Files to be generated:
β invoice/routes/invoice_routes.go
β invoice/controllers/invoice_controller.go
β invoice/services/invoice_service.go
β invoice/repositories/invoice_repository.go
gogen follows a clean, modular structure:
controllers/: HTTP handlers for CRUD endpointsservices/: Business logic layerrepositories/: Data access layerroutes/: Fiber route definitions
Each resource is self-contained under its own directory, supporting maintainable and testable code organization.
Contributions are welcome. To contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -m 'feat: add new feature') - Push to your branch (
git push origin feature/your-feature) - Open a pull request
This project is licensed under the MIT License. See the LICENSE file for details.
Zaheer Shaikh
GitHub: @zaheershaikh936
**Windows:**
Download `gogen_Windows_x86_64.zip` from releases and add to your PATH.
## π Quick Start
# Setup
### Check where Go installs binaries
export PATH=$PATH:$(go env GOPATH)/bin
### Generate a CRUD Resource
```bash
# Basic usage
gogen resource user
# Custom output directory
gogen resource product --output ./api
# Short flag
gogen resource order -o ./src
users/
βββ controllers/
β βββ users_controller.go # HTTP handlers (GetAll, Get, Create, Update, Delete)
βββ services/
β βββ users_service.go # Business logic layer
βββ repositories/
β βββ users_repository.go # Database operations
βββ routes/
βββ users_routes.go # Fiber route definitions
Gogen follows clean architecture principles:
your-project/
βββ controllers/ # HTTP handlers (presentation layer)
βββ services/ # Business logic
βββ repositories/ # Data access layer
βββ routes/ # API route definitions
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add 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.
If you find this project useful, please give it a βοΈ on GitHub!
Zaheer Shaikh - @zaheershaikh936
Project Link: https://github.com/zaheershaikh936/gogen
Made with β€οΈ by Zaheer Shaikh