Introduction
GoFrame (GF) is a comprehensive Go application framework that bundles an HTTP server, database ORM, caching, configuration management, and a development CLI. It targets teams building production web services who want convention over configuration without stitching together separate libraries.
What GoFrame Does
- Provides a high-performance HTTP server with middleware and routing groups
- Includes a full ORM with model generation, transactions, and soft deletes
- Manages configuration from files, environment variables, and remote sources
- Ships a CLI tool for project scaffolding, code generation, and database migration
- Offers built-in modules for logging, validation, i18n, and scheduled tasks
Architecture Overview
GoFrame follows a modular monolith design where each subsystem (HTTP, ORM, cache, config, log) is an independent module behind a unified API. The core container provides dependency injection, and modules communicate through well-defined interfaces. The ORM uses a chainable query builder on top of database/sql with driver adapters for MySQL, PostgreSQL, SQLite, and others.
Self-Hosting & Configuration
- Install the CLI:
go install github.com/gogf/gf/cmd/gf/v2@latest - Scaffold a project:
gf init projectname - Configure via
manifest/config/config.yamlfor server, database, and logging - Generate model and DAO code from database tables:
gf gen dao - Deploy as a single binary; use
gf buildfor cross-platform compilation
Key Features
- Unified framework reduces dependency management overhead
- Code generation accelerates CRUD development with type-safe models
- Context-aware logging and tracing integrate with OpenTelemetry
- Modular design allows using individual components without the full framework
- Active Chinese and English documentation with growing community
Comparison with Similar Tools
- Gin — Lightweight HTTP router only; GoFrame provides ORM, config, and CLI on top
- Beego — Similar full-stack approach but GoFrame has a more modern API and active maintenance
- Echo — Focused on HTTP middleware; lacks built-in ORM and code generation
- Kratos — Microservices-oriented with gRPC focus; GoFrame targets monolithic and modular apps
FAQ
Q: Is GoFrame suitable for microservices? A: Yes. Its modular design lets you use only the HTTP and gRPC components for lightweight services.
Q: How does the ORM compare to GORM? A: GoFrame ORM is tightly integrated with the framework and offers code generation. GORM is standalone and more widely adopted outside GoFrame projects.
Q: Can I use GoFrame with an existing Go project? A: Yes. Individual modules like the HTTP server or ORM can be imported independently.
Q: What databases does GoFrame support? A: MySQL, PostgreSQL, SQLite, Oracle, SQL Server, and ClickHouse via community drivers.