Skip to content

1711naveen/gogen

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Gogen - Go CRUD Generator CLI

Go Version Release License Go Report Card

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.

✨ Features

  • 🎯 One Command Generation - Generate complete CRUD structure instantly
  • πŸ“ Clean Architecture - Follows best practices with separated concerns

gogen

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.

Features

  • 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

Installation

Using Go

go install github.com/zaheershaikh936/gogen@latest

Ensure that your $GOPATH/bin is in your PATH.

Download Prebuilt Binary

  1. Visit Releases
  2. Download the binary for your OS (Windows, Linux, macOS)
  3. Add the binary location to your PATH

CLI Usage

Command Syntax

gogen resource <model> [flags]

Arguments

  • <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.

Flags

Flag Short Default Description
--output -o ./ Output directory for generated files
--help -h Show help for the command

Behavior Notes

  • 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.

Usage Examples

Generate a user resource in the current directory:

gogen resource user

Generate a product resource in a custom directory:

gogen resource product --output ./api

Use the short flag for output directory:

gogen resource order -o ./src

Show help for the resource command:

gogen resource --help

End-to-End Example

Command:

gogen resource invoice --output ./internal/api

Generated folder structure:

internal/api/invoice/
β”œβ”€β”€ controllers/
β”‚   └── invoice_controller.go
β”œβ”€β”€ services/
β”‚   └── invoice_service.go
β”œβ”€β”€ repositories/
β”‚   └── invoice_repository.go
└── routes/
    └── invoice_routes.go

Sample CLI Output

πŸš€ 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

Generated Architecture

gogen follows a clean, modular structure:

  • controllers/: HTTP handlers for CRUD endpoints
  • services/: Business logic layer
  • repositories/: Data access layer
  • routes/: Fiber route definitions

Each resource is self-contained under its own directory, supporting maintainable and testable code organization.

Contributing

Contributions are welcome. To contribute:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/your-feature)
  3. Commit your changes (git commit -m 'feat: add new feature')
  4. Push to your branch (git push origin feature/your-feature)
  5. Open a pull request

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author

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

Add PATH

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

What Gets Generated?

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

πŸ—οΈ Project Structure

Gogen follows clean architecture principles:

your-project/
β”œβ”€β”€ controllers/   # HTTP handlers (presentation layer)
β”œβ”€β”€ services/      # Business logic
β”œβ”€β”€ repositories/  # Data access layer
└── routes/        # API route definitions

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

🌟 Show Your Support

If you find this project useful, please give it a ⭐️ on GitHub!

πŸ“¬ Contact

Zaheer Shaikh - @zaheershaikh936

Project Link: https://github.com/zaheershaikh936/gogen


Made with ❀️ by Zaheer Shaikh

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Go 100.0%