go-hsr

command module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 5 Imported by: 0

README ΒΆ

Go-HSR Template

Version Go Reference

Go HSR API Forge is a high-performance CLI tool designed to scaffold production-ready REST APIs in Go. It enforces a strict Clean Architecture pattern using the HSR (Handler, Service, Repository) methodology, enabling developers to build scalable microservices and APIs with zero boilerplate overhead.

πŸš€ Why choose HSR?

  • Instant Scaffolding - Generate a complete, industry-standard project structure in one command.
  • Clean Architecture (HSR) - Logic is decoupled across layers (HTTP, Business, Data Access) for maximum testability.
  • Developer First - Includes Docker support, standardized error handling, and robust middleware out of the box.
  • Zero Configuration - Get a database-ready API with GORM and SQLite configured in seconds.

πŸ“¦ Getting Started

Prerequisites
  • Go version: Go 1.22 or above.
Quick Start

Generate a new project directly from the terminal without cloning the repository:

1. Create a standard project:

go run [github.com/AP71/go-hsr@latest](https://github.com/AP71/go-hsr@latest) new ./my-new-api

2. Create a project with SQLite database support:

go run [github.com/AP71/go-hsr@latest](https://github.com/AP71/go-hsr@latest) new ./my-secured-api --auth
Next Steps

After generating your project:

cd my-new-api
go mod tidy
go run main.go

πŸ—οΈ Project Structure

my-new-api/
β”œβ”€β”€ config/             # Database and backup configurations
β”œβ”€β”€ docs/               # Swagger/OpenAPI documentation
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ dto/            # Data Transfer Objects
β”‚   β”œβ”€β”€ handler/        # HTTP controllers
β”‚   β”œβ”€β”€ middleware/     # Auth and security layers
β”‚   β”œβ”€β”€ model/          # GORM domain entities
β”‚   β”œβ”€β”€ repository/     # Data access layer
β”‚   β”œβ”€β”€ router/         # Gin router initialization
β”‚   └── service/        # Business logic
β”œβ”€β”€ pkg/apperror/       # Standardized error mapping
β”œβ”€β”€ utils/              # JWT, Hashing, and helper functions
β”œβ”€β”€ docker-compose.yml  # Container orchestration
└── Dockerfile          # Multi-stage production build

πŸ“– Documentation

Swagger API Reference

This project integrates swaggo/swag for automated API documentation.

  1. Install Swag CLI:
go install [github.com/swaggo/swag/cmd/swag@latest](https://github.com/swaggo/swag/cmd/swag@latest)
  1. Generate Swagger Docs:
swag init
  1. View API Docs: Run the application and navigate to http://localhost:8080/swagger/index.html to view the interactive API documentation.

🀝 Contributing

We welcome contributions! Please feel free to open issues or submit pull requests.

πŸ“ License

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

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

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