gf

package module
v2.10.6 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 0 Imported by: 24 modules, 55 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

English | 简体中文

goframe logo

Go Reference GoFrame CI Code Coverage Production Ready License Ask DeepWiki

Release GitHub pull requests GitHub closed pull requests GitHub issues GitHub closed issues Stars Forks

GoFrame is a powerful framework for faster, easier, and more efficient project development. Use it as a full application framework, or pick individual components as needed.

Installation

GoFrame requires Go 1.25 or later.

In an existing module, add the framework:

go get -v github.com/gogf/gf/v2@latest

Install the gf CLI:

go install github.com/gogf/gf/cmd/gf/v2@latest

Documentation

Usage

Create main.go:

package main

import (
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/net/ghttp"
)

func main() {
	s := g.Server()
	s.BindHandler("/", func(r *ghttp.Request) {
		r.Response.Write("Hello World!")
	})
	s.SetPort(8000)
	s.Run()
}

Run it:

go mod init hello
go mod tidy
go run main.go

Open http://127.0.0.1:8000.

To scaffold a project with the gf CLI:

gf init hello
cd hello && gf run main.go

Feature Map

GoFrame is a collection of independent modules. Use it as a full application framework, or import only the packages you need.

Application framework

Runtime components required to build a complete application: entry facade, network communication, data access and common services.

Top-level package Sub-packages Description
frame/ g, gins Application facade and singleton container. g exposes global entry points such as g.Server(), g.DB() and g.Cfg(); gins handles singleton registration and core component instance management
net/ ghttp, gclient, gtcp, gudp, gipv4, gipv6 Network communication. ghttp provides routing, middleware, static files, WebSocket and graceful restart; gclient provides a chainable HTTP client; gtcp/gudp provide TCP/UDP server and client; gipv4/gipv6 provide IP address parsing and validation
database/ gdb, gredis Data access. gdb is a driver-agnostic ORM supporting models, transactions, soft delete, sharding and hooks; gredis defines the Redis client abstraction with single, cluster and sentinel modes
os/ gcfg, glog, gcache, gsession, gview, gcron, gtimer Application services. Config supports multiple formats and hot reload; logging supports leveled output, file rotation and trace context; cache provides in-memory LRU with expiry and pluggable adapters; session supports file, memory and Redis storage; template supports built-in functions and i18n; cron supports second-level schedules, intervals and one-shot timers

Service governance

Abstraction layer for microservice scenarios. It defines interfaces and common capabilities only; concrete implementations live in contrib/.

Top-level package Sub-packages Description
net/ gsvc, gsel, gtrace, goai gsvc defines service registry and discovery interfaces; gsel defines load-balancing selectors; gtrace wraps OpenTelemetry tracing; goai generates OpenAPI documents
os/ gmetric Metric abstraction layer defining Counter, UpDownCounter, Histogram and the observable variants ObservableCounter, ObservableUpDownCounter and ObservableGauge. See contrib/metric/otelmetric for the reporting implementation

Utility libraries

General-purpose capabilities that can be imported independently without the framework runtime.

Top-level package Sub-packages Description
os/ gfile, gfsnotify, gproc, grpool, gfpool, gctx, genv, gtime, gres, gspath, gstructs, gbuild, gcmd, gmlock, gmutex System and runtime utilities. File I/O, file watching, process management, goroutine pool, file pointer pool, context, environment variables, time handling, resource management, search path, struct reflection, build info, CLI parsing, memory lock, mutex
container/ garray, gmap, gset, glist, gqueue, gring, gtree, gpool, gtype, gvar Concurrent-safe containers. Array, map, set, list, queue, ring, tree, object pool, type wrapper and generic variable, all safe for concurrent access
encoding/ gjson, gyaml, gtoml, gini, gxml, gproperties, gbase64, gbinary, gcharset, gcompress, ghash, ghtml, gurl Codecs and format conversion. JSON, YAML, TOML, INI, XML and Properties parsing; Base64, binary, charset conversion, compression, hashing, HTML escaping and URL encoding
crypto/ gaes, gdes, grsa, gmd5, gsha1, gsha256, gsha512, gcrc32 Encryption and digests. AES and DES symmetric encryption, RSA asymmetric encryption, MD5, SHA1, SHA256 and SHA512 digests, CRC32 checksums
util/ gconv, gvalid, gmeta, gtag, gmode, gpage, grand, guid, gutil General utilities. Type conversion, validation, metadata, struct tags, run mode (develop, testing, staging, product), pagination, random numbers and unique IDs
text/ gstr, gregex Text processing. String search, replace, split and format; regex wrapper
errors/ gerror, gcode Error handling. gerror provides stack-aware error wrapping; gcode defines standard error codes
i18n/ gi18n Internationalization with multi-language resource loading and translation
debug/ gdebug Debug helpers for printing call stacks and variable information
test/ gtest Unit test helpers providing gtest.C blocks and fluent assertions

Ecosystem modules (contrib/)

Standalone modules that require a separate go get, grouped by domain.

Area Modules Description
Database drivers mysql, pgsql, mssql, oracle, sqlite, sqlitecgo, clickhouse, dm, gaussdb, mariadb, oceanbase, tidb Database driver implementations for gdb, registered into the framework via blank import
Config adapters apollo, consul, nacos, polaris, kubecm Remote config source adapters for gcfg, supporting config watching and hot reload
Service registry etcd, consul, nacos, polaris, zookeeper, file Service registry and discovery implementations for gsvc; file is a local file implementation suited for development and debugging
RPC grpcx gRPC-based RPC component integrating service registry, load balancing and tracing
Tracing / metrics otlpgrpc, otlphttp, otelmetric OpenTelemetry implementations for gtrace and gmetric, supporting both gRPC and HTTP exporters
Redis adapter redis Adapter implementation for gredis based on go-redis, also usable as the storage backend for gcache and gsession
SDK utilities httpclient HTTP client wrapper for SDK scenarios, supporting custom response handlers and request/response logging

Command-line tool

The gf CLI ships with GoFrame and covers daily development tasks such as project scaffolding, code generation, building and deployment.

Commonly used commands:

Command Description
gf init Create and initialize an empty GoFrame project
gf run Run Go code with hot-compiled-like behavior
gf gen dao Generate dao, do and entity code from database tables
gf gen ctrl Parse api definitions and generate controller and SDK code
gf build Cross-build the project for multiple platforms and architectures

See cmd/gf for the full command list and usage details.

Contributors

💖 Thanks to all the contributors who made GoFrame possible 💖

goframe contributors

License

GoFrame is licensed under the MIT License, 100% free and open-source, forever.

Documentation

Index

Constants

View Source
const (
	// VERSION is the current GoFrame version.
	VERSION = "v2.10.6"
)

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
container
garray
Package garray provides most commonly used array containers which also support concurrent-safe/unsafe switch feature.
Package garray provides most commonly used array containers which also support concurrent-safe/unsafe switch feature.
glist
Package glist provides most commonly used doubly linked list container which also supports concurrent-safe/unsafe switch feature.
Package glist provides most commonly used doubly linked list container which also supports concurrent-safe/unsafe switch feature.
gmap
Package gmap provides most commonly used map container which also support concurrent-safe/unsafe switch feature.
Package gmap provides most commonly used map container which also support concurrent-safe/unsafe switch feature.
gpool
Package gpool provides object-reusable concurrent-safe pool.
Package gpool provides object-reusable concurrent-safe pool.
gqueue
Package gqueue provides dynamic/static concurrent-safe queue.
Package gqueue provides dynamic/static concurrent-safe queue.
gring
Package gring provides a concurrent-safe/unsafe ring(circular lists).
Package gring provides a concurrent-safe/unsafe ring(circular lists).
gset
Package gset provides kinds of concurrent-safe/unsafe sets.
Package gset provides kinds of concurrent-safe/unsafe sets.
gtree
Package gtree provides concurrent-safe/unsafe tree containers.
Package gtree provides concurrent-safe/unsafe tree containers.
gtype
Package gtype provides high performance and concurrent-safe basic variable types.
Package gtype provides high performance and concurrent-safe basic variable types.
gvar
Package gvar provides an universal variable type, like runtime generics.
Package gvar provides an universal variable type, like runtime generics.
crypto
gaes
Package gaes provides useful API for AES encryption/decryption algorithms.
Package gaes provides useful API for AES encryption/decryption algorithms.
gcrc32
Package gcrc32 provides useful API for CRC32 encryption algorithms.
Package gcrc32 provides useful API for CRC32 encryption algorithms.
gdes
Package gdes provides useful API for DES encryption/decryption algorithms.
Package gdes provides useful API for DES encryption/decryption algorithms.
gmd5
Package gmd5 provides useful API for MD5 encryption algorithms.
Package gmd5 provides useful API for MD5 encryption algorithms.
grsa
Package grsa provides useful API for RSA encryption/decryption algorithms.
Package grsa provides useful API for RSA encryption/decryption algorithms.
gsha1
Package gsha1 provides useful API for SHA1 encryption algorithms.
Package gsha1 provides useful API for SHA1 encryption algorithms.
gsha256
Package gsha256 provides useful API for SHA256 encryption algorithms.
Package gsha256 provides useful API for SHA256 encryption algorithms.
gsha512
Package gsha512 provides useful API for SHA512 encryption algorithms.
Package gsha512 provides useful API for SHA512 encryption algorithms.
database
gdb
Package gdb provides ORM features for popular relationship databases.
Package gdb provides ORM features for popular relationship databases.
gredis
Package gredis provides convenient client for redis server.
Package gredis provides convenient client for redis server.
debug
gdebug
Package gdebug contains facilities for programs to debug themselves while they are running.
Package gdebug contains facilities for programs to debug themselves while they are running.
encoding
gbase64
Package gbase64 provides useful API for BASE64 encoding/decoding algorithm.
Package gbase64 provides useful API for BASE64 encoding/decoding algorithm.
gbinary
Package gbinary provides useful API for handling binary/bytes data.
Package gbinary provides useful API for handling binary/bytes data.
gcharset
Package gcharset implements character-set conversion functionality.
Package gcharset implements character-set conversion functionality.
gcompress
Package gcompress provides kinds of compression algorithms for binary/bytes data.
Package gcompress provides kinds of compression algorithms for binary/bytes data.
ghash
Package ghash provides some classic hash functions(uint32/uint64) in go.
Package ghash provides some classic hash functions(uint32/uint64) in go.
ghtml
Package ghtml provides useful API for HTML content handling.
Package ghtml provides useful API for HTML content handling.
gini
Package gini provides accessing and converting for INI content.
Package gini provides accessing and converting for INI content.
gjson
Package gjson provides convenient API for JSON/XML/INI/YAML/TOML data handling.
Package gjson provides convenient API for JSON/XML/INI/YAML/TOML data handling.
gproperties
Package gproperties provides accessing and converting for .properties content.
Package gproperties provides accessing and converting for .properties content.
gtoml
Package gtoml provides accessing and converting for TOML content.
Package gtoml provides accessing and converting for TOML content.
gurl
Package gurl provides useful API for URL handling.
Package gurl provides useful API for URL handling.
gxml
Package gxml provides accessing and converting for XML content.
Package gxml provides accessing and converting for XML content.
gyaml
Package gyaml provides accessing and converting for YAML content.
Package gyaml provides accessing and converting for YAML content.
errors
gcode
Package gcode provides universal error code definition and common error codes implements.
Package gcode provides universal error code definition and common error codes implements.
gerror
Package gerror provides rich functionalities to manipulate errors.
Package gerror provides rich functionalities to manipulate errors.
frame
g
Package g provides commonly used type/function defines and coupled calling for creating commonly-used objects.
Package g provides commonly used type/function defines and coupled calling for creating commonly-used objects.
gins
Package gins provides instances and core components management.
Package gins provides instances and core components management.
i18n
gi18n
Package gi18n implements internationalization and localization.
Package gi18n implements internationalization and localization.
internal
command
Package command provides console operations, like options/arguments reading.
Package command provides console operations, like options/arguments reading.
consts
Package consts defines constants that are shared all among packages of framework.
Package consts defines constants that are shared all among packages of framework.
deepcopy
Package deepcopy makes deep copies of things using reflection.
Package deepcopy makes deep copies of things using reflection.
empty
Package empty provides functions for checking empty/nil variables.
Package empty provides functions for checking empty/nil variables.
errors
Package errors provides functionalities to manipulate errors for internal usage purpose.
Package errors provides functionalities to manipulate errors for internal usage purpose.
fileinfo
Package fileinfo provides virtual os.FileInfo for given information.
Package fileinfo provides virtual os.FileInfo for given information.
httputil
Package httputil provides HTTP functions for internal usage only.
Package httputil provides HTTP functions for internal usage only.
instance
Package instance provides instances management.
Package instance provides instances management.
intlog
Package intlog provides internal logging for GoFrame development usage only.
Package intlog provides internal logging for GoFrame development usage only.
json
Package json provides json operations wrapping ignoring stdlib or third-party lib json.
Package json provides json operations wrapping ignoring stdlib or third-party lib json.
mutex
Package mutex provides switch of concurrent safe feature for sync.Mutex.
Package mutex provides switch of concurrent safe feature for sync.Mutex.
reflection
Package reflection provides some reflection functions for internal usage.
Package reflection provides some reflection functions for internal usage.
rwmutex
Package rwmutex provides switch of concurrent safety feature for sync.RWMutex.
Package rwmutex provides switch of concurrent safety feature for sync.RWMutex.
tracing
Package tracing provides some utility functions for tracing functionality.
Package tracing provides some utility functions for tracing functionality.
utils
Package utils provides some utility functions for internal usage.
Package utils provides some utility functions for internal usage.
net
gclient
Package gclient provides convenient http client functionalities.
Package gclient provides convenient http client functionalities.
ghttp
Package ghttp provides powerful http server and simple client implements.
Package ghttp provides powerful http server and simple client implements.
ghttp/internal/graceful
Package graceful implements graceful reload/restart features for HTTP servers.
Package graceful implements graceful reload/restart features for HTTP servers.
ghttp/internal/response
Package response provides wrapper for http.response.
Package response provides wrapper for http.response.
ghttp/internal/swaggerui
Package swaggerui provides packed swagger ui static files using resource manager.
Package swaggerui provides packed swagger ui static files using resource manager.
gipv6
Package gipv6 provides useful API for IPv6 address handling.
Package gipv6 provides useful API for IPv6 address handling.
goai
Package goai implements and provides document generating for OpenApi specification.
Package goai implements and provides document generating for OpenApi specification.
gsel
Package gsel provides selector definition and implements.
Package gsel provides selector definition and implements.
gsvc
Package gsvc provides service registry and discovery definition.
Package gsvc provides service registry and discovery definition.
gtcp
Package gtcp provides TCP server and client implementations.
Package gtcp provides TCP server and client implementations.
gtrace
Package gtrace provides convenience wrapping functionality for tracing feature using OpenTelemetry.
Package gtrace provides convenience wrapping functionality for tracing feature using OpenTelemetry.
gudp
Package gudp provides UDP server and client implementations.
Package gudp provides UDP server and client implementations.
os
gbuild
Package gbuild manages the built-in variables from "gf build".
Package gbuild manages the built-in variables from "gf build".
gcache
Package gcache provides kinds of cache management for process.
Package gcache provides kinds of cache management for process.
gcfg
Package gcfg provides reading, caching and managing for configuration.
Package gcfg provides reading, caching and managing for configuration.
gcmd
Package gcmd provides console operations, like options/arguments reading and command running.
Package gcmd provides console operations, like options/arguments reading and command running.
gcron
Package gcron implements a cron pattern parser and job runner.
Package gcron implements a cron pattern parser and job runner.
gctx
Package gctx wraps context.Context and provides extra context features.
Package gctx wraps context.Context and provides extra context features.
genv
Package genv provides operations for environment variables of system.
Package genv provides operations for environment variables of system.
gfile
Package gfile provides easy-to-use operations for file system.
Package gfile provides easy-to-use operations for file system.
gfpool
Package gfpool provides io-reusable pool for file pointer.
Package gfpool provides io-reusable pool for file pointer.
gfsnotify
Package gfsnotify provides a platform-independent interface for file system notifications.
Package gfsnotify provides a platform-independent interface for file system notifications.
glog
Package glog implements powerful and easy-to-use leveled logging functionality.
Package glog implements powerful and easy-to-use leveled logging functionality.
gmetric
Package gmetric provides interface definitions and simple api for metric feature.
Package gmetric provides interface definitions and simple api for metric feature.
gmlock
Package gmlock implements a concurrent-safe memory-based locker.
Package gmlock implements a concurrent-safe memory-based locker.
gmutex
Package gmutex inherits and extends sync.Mutex and sync.RWMutex with more futures.
Package gmutex inherits and extends sync.Mutex and sync.RWMutex with more futures.
gproc
Package gproc implements management and communication for processes.
Package gproc implements management and communication for processes.
gres
Package gres provides resource management and packing/unpacking feature between files and bytes.
Package gres provides resource management and packing/unpacking feature between files and bytes.
grpool
Package grpool implements a goroutine reusable pool.
Package grpool implements a goroutine reusable pool.
gsession
Package gsession implements manager and storage features for sessions.
Package gsession implements manager and storage features for sessions.
gspath
Package gspath implements file index and search for folders.
Package gspath implements file index and search for folders.
gstructs
Package gstructs provides functions for struct information retrieving.
Package gstructs provides functions for struct information retrieving.
gtime
Package gtime provides functionality for measuring and displaying time.
Package gtime provides functionality for measuring and displaying time.
gtimer
Package gtimer implements timer for interval/delayed jobs running and management.
Package gtimer implements timer for interval/delayed jobs running and management.
gview
Package gview implements a template engine based on text/template.
Package gview implements a template engine based on text/template.
test
gtest
Package gtest provides convenient test utilities for unit testing.
Package gtest provides convenient test utilities for unit testing.
text
gregex
Package gregex provides high performance API for regular expression functionality.
Package gregex provides high performance API for regular expression functionality.
gstr
Package gstr provides functions for string handling.
Package gstr provides functions for string handling.
util
gconv
Package gconv implements powerful and convenient converting functionality for any types of variables.
Package gconv implements powerful and convenient converting functionality for any types of variables.
gconv/internal/converter
Package converter provides converting utilities for any types of variables.
Package converter provides converting utilities for any types of variables.
gconv/internal/localinterface
Package localinterface defines some interfaces for converting usage.
Package localinterface defines some interfaces for converting usage.
gconv/internal/structcache
Package structcache provides struct and field info cache feature to enhance performance for struct converting.
Package structcache provides struct and field info cache feature to enhance performance for struct converting.
gmeta
Package gmeta provides embedded meta data feature for struct.
Package gmeta provides embedded meta data feature for struct.
gmode
Package gmode provides release mode management for project.
Package gmode provides release mode management for project.
gpage
Package gpage provides useful paging functionality for web pages.
Package gpage provides useful paging functionality for web pages.
grand
Package grand provides high performance random bytes/number/string generation functionality.
Package grand provides high performance random bytes/number/string generation functionality.
gtag
Package gtag providing tag content storing for struct.
Package gtag providing tag content storing for struct.
guid
Package guid provides simple and high performance unique id generation functionality.
Package guid provides simple and high performance unique id generation functionality.
gutil
Package gutil provides utility functions.
Package gutil provides utility functions.
gvalid
Package gvalid implements powerful and useful data/form validation functionality.
Package gvalid implements powerful and useful data/form validation functionality.
gvalid/internal/builtin
Package builtin implements built-in validation rules.
Package builtin implements built-in validation rules.

Jump to

Keyboard shortcuts

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