cli-generator

command module
v0.0.0-...-20e4642 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 7 Imported by: 0

README ΒΆ

GoInit - Go Gin API Generator

Go Report Card GoDoc

A powerful CLI tool to generate production-ready Go API projects built with the Gin framework.

πŸš€ Installation

go install github.com/rou/goinit@latest
Option 2: Download Binary

Download the latest release from GitHub Releases

Option 3: Build from Source
git clone https://github.com/rou/goinit.git
cd goinit
go build -o goinit .

πŸ“– Usage

goinit

Follow the interactive prompts to configure your new Go API project.

✨ Features

  • Interactive Setup: Step-by-step project configuration
  • Multiple Databases: SQLite, MySQL, PostgreSQL support
  • Authentication: JWT and session-based auth
  • Real-time: SSE and WebSocket endpoints
  • Email Integration: SMTP and local email logging
  • File Storage: Local and S3-compatible storage
  • Admin Panel: Built-in admin functionality
  • API Documentation: Auto-generated Swagger docs
  • Docker Support: Ready-to-deploy containers
  • Smart Module Initialization: Automatically initializes Go modules
  • Module Reference Replacement: Updates all internal module references
  • Automatic Dependency Management: Runs go mod tidy to download all packages

🎯 What You Get

Your generated project includes:

  • βœ… Clean Architecture with dependency injection
  • βœ… User authentication and authorization
  • βœ… Real-time communication (SSE/WebSocket)
  • βœ… Database models with GORM
  • βœ… Email service with templates
  • βœ… File upload and storage
  • βœ… Admin dashboard endpoints
  • βœ… Swagger API documentation
  • βœ… Docker configuration
  • βœ… Comprehensive README and setup instructions

πŸ“‹ Requirements

  • Go 1.19 or later
  • Git

πŸ› οΈ Configuration Options

During setup, you can configure:

  • Project Name: Your API project name
  • Go Module: Module path (e.g., github.com/username/project)
  • Database: SQLite (default), MySQL, or PostgreSQL
  • Port: Server port (default: 8080)

πŸ”§ Smart Module Management

GoInit includes intelligent module management features:

Automatic Go Module Initialization
  • Checks for existing go.mod: If a go.mod file already exists, it skips initialization
  • Runs go mod init: Automatically initializes a new Go module with your specified module name
  • No manual setup required: The generated project is ready to use immediately
Module Reference Replacement
  • Scans all Go files: Searches through all generated Go files for module references
  • Replaces old references: Updates any hardcoded module references with your custom module name
  • Maintains consistency: Ensures all internal imports use the correct module path
Example
# User specifies: github.com/mycompany/myapi
# GoInit will:
# 1. Run: go mod init github.com/mycompany/myapi
# 2. Replace any "github.com/SOG-web/goinit" references with "github.com/mycompany/myapi"
# 3. Run: go mod tidy (downloads all dependencies)
# 4. Generate a fully functional project ready to run

πŸ“ Generated Project Structure

your-project/
β”œβ”€β”€ cmd/api/                 # Application entry point
β”œβ”€β”€ config/                  # Configuration management
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ app/                # Application services
β”‚   β”œβ”€β”€ data/               # Data layer (repositories)
β”‚   β”œβ”€β”€ domain/             # Domain models
β”‚   β”œβ”€β”€ lib/                # Shared libraries
β”‚   └── server/             # Server setup
β”œβ”€β”€ api/                    # HTTP handlers and routes
β”œβ”€β”€ docs/                   # API documentation
β”œβ”€β”€ .env                    # Environment configuration
β”œβ”€β”€ go.mod                  # Go module file
β”œβ”€β”€ README.md               # Project documentation
└── Dockerfile              # Docker configuration

πŸš€ Quick Start with Generated Project

# Navigate to your new project
cd your-project-name

# Dependencies are already downloaded by GoInit
# Configure environment (optional)
# Edit .env file with your settings

# Run the server
go run cmd/api/main.go

Visit http://localhost:8080 and http://localhost:8080/docs for API documentation.

πŸ“š API Endpoints

Authentication
  • POST /api/auth/register/ - User registration
  • POST /api/auth/login/ - User login
  • GET /api/auth/logout/ - User logout
Real-time
  • GET /api/sse/events - Server-Sent Events
  • GET /api/ws/connect - WebSocket connection
Admin
  • GET /api/admin/users/ - List users
  • GET /api/admin/stats/ - User statistics

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

πŸ“„ License

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

πŸ™ Acknowledgments


Happy coding! πŸŽ‰

Test change for hook

Test commit

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL