A powerful, enterprise-grade Go web framework inspired by NestJS, designed for building scalable, maintainable applications with modern architectural patterns.
- ποΈ Modular Architecture: NestJS-style module system with dependency injection
- π Lifecycle Management: Comprehensive application and module lifecycle hooks
- π‘οΈ Built-in Security: Guards, interceptors, and authentication systems
- π Database Integration: MongoDB support with Mongoose-like ODM
- π WebSocket Support: Real-time communication capabilities
- β‘ High Performance: Built on Echo framework for optimal performance
- π§ͺ Testing Utilities: Built-in testing framework and utilities
- π Validation: Request/response validation with struct tags
- π― CLI Tools: Code generation and project management tools
When you create a new GoNest application, you'll get a well-organized project structure that follows Go and NestJS best practices:
my-gonest-app/
βββ cmd/
β βββ server/
β βββ main.go # Application entry point
βββ internal/
β βββ modules/ # Feature modules (business domains)
β β βββ user/ # User module example
β β β βββ user_module.go # Module definition and DI setup
β β β βββ user_service.go # Business logic layer
β β β βββ user_controller.go # HTTP request handlers
β β β βββ user_dto.go # Data transfer objects
β β βββ auth/ # Authentication module
β βββ config/ # Configuration management
β β βββ config.go
β βββ middleware/ # Custom middleware
β βββ shared/ # Shared utilities and types
βββ pkg/ # Public packages (if needed)
βββ scripts/ # Build and deployment scripts
βββ docs/ # Project documentation
βββ tests/ # Integration and e2e tests
βββ .env # Environment variables
βββ .gitignore # Git ignore rules
βββ go.mod # Go module definition
βββ go.sum # Dependency checksums
βββ Dockerfile # Container configuration
βββ docker-compose.yml # Multi-service setup
βββ README.md # Project documentation
Each feature module follows a consistent, flat structure inspired by NestJS:
internal/modules/user/
βββ user_module.go # Module registration and dependency injection
βββ user_controller.go # HTTP request handling
βββ user_service.go # Business logic implementation
βββ user_dto.go # Request/response data structures
βββ user_entity.go # Domain entities/models
βββ user_repository.go # Data access layer (if needed)
To get started, you can either use our CLI tool (recommended), automated setup scripts, or manually set up your project. All approaches will produce the same outcome.
Our CLI tool provides the fastest and most reliable way to create a new GoNest project:
# 1. Clone the GoNest repository
$ git clone https://github.com/ulims/GoNest.git
$ cd GoNest
# 2. Build the CLI tool
$ go build -o gonest.exe cmd/gonest/main.go
# 3. Create a new project
$ ./gonest.exe new my-project-name
# 4. Create with specific template and strict mode
$ ./gonest.exe new my-api --template=api --strictThe CLI tool automatically:
- β Create the recommended project structure
- β Initialize Go module and Git repository
- β Install all GoNest dependencies
- β Generate configuration files
- β Set up Docker and build automation
- β Create comprehensive documentation
- β Support multiple project templates
- β Generate components (modules, controllers, services)
HINT
The CLI tool is the most reliable way to get started. It handles all dependencies and creates a production-ready project structure.
If you prefer to use our setup scripts directly:
# Clone the GoNest repository
$ git clone https://github.com/ulims/GoNest.git
$ cd GoNest
# Make the script executable and run it
$ chmod +x scripts/setup-project.sh
$ ./scripts/setup-project.sh my-project-name# Clone the GoNest repository
$ git clone https://github.com/ulims/GoNest.git
$ cd GoNest
# Run the batch script
$ scripts\setup-project.batIf you prefer to set up manually:
# Create a new directory for your project
$ mkdir my-gonest-app
$ cd my-gonest-app
# Initialize Go module
$ go mod init my-gonest-app
# Add GoNest dependency
$ go get github.com/ulims/GoNestpackage main
import (
"context"
"github.com/sirupsen/logrus"
gonest "github.com/ulims/GoNest"
)
func main() {
// Initialize logger
logger := logrus.New()
logger.SetLevel(logrus.InfoLevel)
// Create application
app := gonest.NewApplication().
Config(&gonest.Config{
Port: "8080",
Host: "localhost",
Environment: "development",
}).
Logger(logger).
Build()
// Start application
if err := app.Start(); err != nil {
logger.Fatal("Failed to start application:", err)
}
}go run main.goYour application will be available at http://localhost:8080
- π Full Documentation - Comprehensive framework guide
- ποΈ Architecture Guide - Detailed architectural patterns
- π Quick Start Guide - Step-by-step project setup
- π οΈ CLI Tool Guide - Complete guide for using the CLI tool
- π Features Overview - All available features
- π§ͺ Examples - Working examples and tutorials
- π§ Setup Scripts - Automated project initialization
GoNest follows proven architectural patterns inspired by NestJS:
- ποΈ Modular Design: Organize code into feature modules with clear boundaries
- π Dependency Injection: Automatic dependency resolution and injection
- π± Flat Module Structure: Keep module files organized without deep nesting
- π Separation of Concerns: Controllers handle HTTP, Services handle business logic
- π§ͺ Testable by Design: Easy to mock and test individual components
- π Consistent Patterns: Every module follows the same organizational structure
// Create a complete user module in minutes
userModule := gonest.NewModule("UserModule").
Controller(userController).
Service(userService).
Build()
app.ModuleRegistry.Register(userModule)GoNest includes a powerful CLI tool for project scaffolding and component generation. This is the recommended way for developers to get started with GoNest.
Get started in seconds! This installer handles everything automatically.
Linux/macOS:
$ curl -sSL https://raw.githubusercontent.com/ulims/GoNest/master/install-gonest.sh | bashWindows:
# Download and run the installer
$ curl -o install-gonest.bat https://raw.githubusercontent.com/ulims/GoNest/master/install-gonest.bat && install-gonest.batβ What happens automatically:
- CLI tool installed globally
- All dependencies handled
- Ready to use immediately
Manual Installation:
# Clone and install manually
$ git clone https://github.com/ulims/GoNest.git
$ cd GoNest
$ go install ./cmd/gonest
# Verify installation
$ gonest --helpBuild from Source:
# Clone and build locally
$ git clone https://github.com/ulims/GoNest.git
$ cd GoNest
$ go build -o gonest.exe cmd/gonest/main.go # Windows
$ go build -o gonest cmd/gonest/main.go # Linux/macOS# Basic project
$ gonest new my-app
# Navigate to your project
$ cd my-app
# Dependencies are downloaded automatically by the CLI
# But if you encounter issues, manually run:
$ go mod tidy
# Run your application
$ go run cmd/server/main.go# API project with strict mode
$ gonest new my-api --template=api --strict
# Full-stack project
$ gonest new my-webapp --template=fullstack
# Microservice project
$ gonest new my-service --template=microservice# Navigate to your GoNest project
$ cd my-app
# Generate a new module
$ gonest generate module user
# Generate a controller
$ gonest generate controller user
# Generate a service
$ gonest generate service user
# Generate DTOs and entities
$ gonest generate dto user
$ gonest generate entity user# Build the application
$ gonest build
# Run the application
$ gonest run
# Run tests
$ gonest test| Template | Description | Use Case |
|---|---|---|
basic |
Standard GoNest structure | General applications |
api |
API-focused with Swagger | REST APIs, microservices |
fullstack |
Web app with templates | Full-stack applications |
microservice |
gRPC + protobuf | Microservice architecture |
| Command | Description | Example |
|---|---|---|
new |
Create new project | gonest new my-app |
generate |
Generate components | gonest generate module user |
build |
Build application | gonest build |
run |
Run application | gonest run |
test |
Run tests | gonest test |
Enable strict mode for enhanced security and validation:
$ gonest new my-app --strictStrict mode includes:
- Enhanced input validation
- Security headers
- Rate limiting
- CORS configuration
- Request logging
basic(default): Standard GoNest project structureapi: API-focused project with Swagger documentationfullstack: Full-stack application with web templatesmicroservice: Microservice with gRPC and protobuf support
Enable additional validation and security features with --strict flag.
type UserModule struct {
*gonest.Module
}
func NewUserModule(logger *logrus.Logger) *UserModule {
userService := NewUserService(logger)
userController := NewUserController(userService)
module := gonest.NewModule("UserModule").
Controller(userController).
Service(userService).
Build()
return &UserModule{Module: module}
}type UserService struct {
users map[string]*User
logger *logrus.Logger
}
func (s *UserService) CreateUser(username, email, password string) (*User, error) {
// Business logic implementation
}type UserController struct {
userService *UserService
}
func (c *UserController) CreateUser(ctx echo.Context) error {
// HTTP request handling
}GoNest provides built-in testing utilities:
func TestUserService(t *testing.T) {
testApp := gonest.NewTestApp().
Module(userModule).
Build()
// Test with real HTTP requests
response := testApp.Request("POST", "/users").
WithJSON(map[string]interface{}{
"username": "testuser",
"email": "test@example.com",
}).
ExpectStatus(201).
Get()
assert.NotNil(t, response.JSON())
}- High Throughput: Built on Echo framework for optimal performance
- Low Memory Usage: Efficient memory management and garbage collection
- Fast Startup: Minimal initialization overhead
- Scalable: Support for horizontal and vertical scaling
- Input Validation: Comprehensive request validation
- Authentication: JWT-based authentication system
- Authorization: Role-based access control
- Rate Limiting: Built-in rate limiting strategies
- CORS Support: Configurable cross-origin resource sharing
- π NestJS Familiarity: If you know NestJS, you'll feel at home
- β‘ Go Performance: Leverage Go's speed and efficiency
- ποΈ Enterprise Ready: Built for production applications
- π§ Developer Experience: Excellent tooling and documentation
- π Rich Ecosystem: Comprehensive feature set out of the box
- π§ͺ Testing First: Built-in testing utilities and patterns
- β‘ Quick Setup: Automated project initialization scripts
missing go.sum entry for module providing package github.com/labstack/echo/v4
Solution:
# Dependencies are downloaded automatically by the CLI
# If you encounter this error, run manually:
cd your-project-directory
go mod tidyThe token '&&' is not a valid statement separator
Solution: Use separate commands in PowerShell:
cd my-app
go run cmd/server/main.gobind: address already in use
Solution: Kill the process using port 8080 or change the port in your application.
We welcome contributions! Please see our Contributing Guide for details.
- π Bug fixes and improvements
- β¨ New features and enhancements
- π Documentation improvements
- π§ͺ Test coverage expansion
- π§ Performance optimizations
This project is licensed under the MIT License - see the LICENSE file for details.
- NestJS Team: For the excellent architectural inspiration
- Echo Framework: For the high-performance HTTP foundation
- Go Community: For the amazing ecosystem and tools
- π Documentation: Full Documentation
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
- π§ Email: your-email@example.com
Build amazing applications with GoNest - The Go framework that brings NestJS elegance to Go! π