This page introduces GoFrame: what it is, its design philosophy, the primary capabilities it provides, and how the major subsystems relate to each other. For installation steps, see Installation and Setup. For a deeper breakdown of the architecture, see Architecture Overview.
GoFrame is a modular, production-grade application development framework for Go. It is distributed as a single core module at github.com/gogf/gf/v2 and extended through independently versioned modules under contrib/. The framework covers the full lifecycle of server-side application development: HTTP serving, database access, configuration, logging, caching, validation, type conversion, and more — all under a consistent API style.
The framework is licensed under the MIT License making it free to use in commercial and open-source projects.
Sources: README.MD1-54
GoFrame is built around three principles:
| Principle | Description |
|---|---|
| Modularity | Each subsystem is a separate package (e.g., net/ghttp, database/gdb, os/gcfg). Packages expose interface types so implementations can be swapped via adapters. |
| Convention over configuration | Packages provide useful defaults. Struct tags (v, d, p, in) drive validation and binding; file discovery for config follows a standard search path. |
| Extensibility via adapters | Core abstractions like gcfg.Adapter, gcache.Adapter, and database/gdb drivers are interfaces. The contrib/ tree provides implementations without modifying the core module. |
Top-level layout:
github.com/gogf/gf/v2 ← core module (go.mod at root)
cmd/gf/ ← gf developer CLI tool
contrib/ ← extension modules (each with own go.mod)
drivers/ ← database drivers
registry/ ← service registry adapters
config/ ← remote config adapters
nosql/redis ← Redis cache adapter
trace/ ← OpenTelemetry exporters
rpc/grpcx ← gRPC integration
Sources: README.MD1-54
GoFrame core module package map:
Sources: README.MD1-54
How the major packages depend on each other:
Sources: README.MD1-54
| Capability | Package | Notes |
|---|---|---|
| HTTP server | net/ghttp | Routing, middleware, OpenAPI generation, graceful shutdown |
| HTTP client | net/ghttp | Fluent API, middleware, request/response dump |
| ORM / database | database/gdb | Fluent model API, transactions, hooks, sharding, soft-delete |
| Database drivers | contrib/drivers/* | MySQL, PostgreSQL, MSSQL, Oracle, SQLite, ClickHouse, DM |
| Configuration | os/gcfg | File adapter (TOML, YAML, JSON, INI); remote adapters via contrib/config/* |
| Logging | os/glog | Leveled logging, file rotation, handler middleware, OpenTelemetry integration |
| Caching | os/gcache | In-memory (LRU) and Redis adapters |
| Validation | util/gvalid | Struct tags, built-in rules, i18n messages, custom rules |
| Type conversion | util/gconv | Struct, Map, Scan, Slice, basic type coercions |
| Template engine | os/gview | Go templates, hot reload, built-in functions |
| CLI framework | os/gcmd | Sub-command registration via reflection, option parsing |
| Developer CLI | cmd/gf | gen dao, gen enums, scaffolding commands |
| gRPC | contrib/rpc/grpcx | gRPC server/client with service registry and tracing |
| Service registry | contrib/registry/* | etcd, ZooKeeper, Polaris, file-based |
| Tracing | contrib/trace/* | OTLP via gRPC or HTTP |
Contrib modules are independent Go modules in the contrib/ directory. Each has its own go.mod and is versioned separately from the core. They extend core abstractions through interface implementations:
Sources: README.MD1-54
gf CLI ToolThe gf binary lives at cmd/gf/ and provides developer tooling. Key commands include:
gf gen dao — generates DAO, model, and do-layer code from a live database schemagf gen enums — extracts Go enum constants and generates descriptor codeFor full CLI documentation, see CLI Tool (gf) and Code Generation.
| Section | Content |
|---|---|
| Installation and Setup | go get, Go version requirements, module paths |
| Architecture Overview | Full subsystem map, dependency directions |
| Core Dependencies | External dependencies declared in go.mod |
| Database ORM (gdb) | ORM package: interfaces, model API, drivers, transactions |
| HTTP Server (ghttp) | Server lifecycle, routing, middleware, OpenAPI |
| CLI Tool (gf) | gf binary, code generation, gcmd framework |
| Core Utilities | gconv, gvalid, glog, gcfg, gcache, gjson, gview, gtime, garray, gutil |
| Extensions and Integrations (contrib) | Drivers, registries, tracing, remote config, gRPC |
| Development and Contribution | CI/CD, contributing guidelines, license |
Sources: README.MD1-54
Refresh this wiki
This wiki was recently refreshed. Please wait 1 day to refresh again.