GoFrame
GF(Go Frame)
is a modular, high-performance, production-grade Go foundational development framework. It provides comprehensive infrastructure and development toolchain, offering commonly used development modules such as caching, logging, queue, array, collection, container, timer, command line, memory lock, object pool, configuration management, resource management, data validation, data encoding, cron jobs, database ORM, TCP/UDP components, process management/communication, etc. Moreover, it includes core components for web service development, such as Router, Cookie, Session, Middleware, service registration, template engine, and it supports hot restart, hot update, domain binding, TLS/HTTPS, Rewrite, etc.
Features
- Modular, loosely-coupled design;
- Rich modules, ready to use;
- Easy to use, easy to maintain;
- High code quality, high unit test coverage;
- Active community with humble and amiable experts;
- Comprehensive documentation and examples;
- Complete localization support in Chinese;
- Designed for team and enterprise use;
Development
GoFrame
originated in Beijing in 2011, from a smart IoT platform project before many current IoT standards existed, and when Go’s standard library and ecosystem were not as rich. It wasn't until 2017 that GoFrame
released its test version, and in 2018, during the 1024 programmer’s festival, it released the official v1.0
version, contributing to the Go ecosystem's development. Since its open-source launch, it has iterated quickly, growing widely favored by developers and enterprises, with many developers contributing. Originally designed for development teams, its development efficiency and maintainability are excellent, with high code quality and abundant unit tests and examples. GoFrame
is currently the best Go development framework with localized Chinese documentation.
Change Log
- At the request of many developers, the minimum
Golang
runtime version required by the framework has been downgraded tov1.11
. - Added new
GoFrame
video tutorial addresses:- bilibili: https://www.bilibili.com/video/av94410029
- Xigua Video: https://www.ixigua.com/pseries/6809291194665796100/
- The rarely-used
guuid
module has been moved to github.com/gogf/guuid as a community-maintained module, keeping the maingf
repository lightweight. - Added
guid
module for efficient, lightweight unique string generation: https://goframe.org/util/guid/index
tool chain
- Toolchain update: https://goframe.org/toolchain/cli
- Added
gf env
command for elegantly viewing currentGolang
environment variable information. - Added
gf mod path
command to copy the currentgo modules
package toGOPATH
, facilitating project development using the originalGOPATH
method. - Made improvements to existing
cli
commands, enhancing user experience; precompiled binary versions areupx
compressed on some platforms, reducing file size for downloading.
container
garray
- https://goframe.org/container/garray/index
- Simplified array usage, supporting variable definitions like
var garray.Array
; - Added
Walk
method for custom array element processing; - Added
ContainsI
method for case-insensitive array element existence checking; - Enhanced unit tests, code coverage at
94%
; - Code refinement, performance improvement;
- Fixed some issues;
gchan
- Due to its limited practical significance, the package has been removed from the main framework;
glist
- https://goframe.org/container/glist/index
- Simplified linked list usage, supporting variable definitions like
var glist.List
; - Enhanced unit tests, code coverage at
99%
;
gmap
- https://goframe.org/container/gmap/index
- Simplified
Map
usage, supporting variable definitions likevar gmap.Map
; - Enhanced unit tests, code coverage at
81%
; - Code refinement, performance improvement;
gset
- https://goframe.org/container/gset/index
- Simplified set usage, supporting variable definitions like
var gset.Set
; - Added
Walk
method for custom set element processing; - Enhanced unit tests, code coverage at
90%
; - Code refinement, performance improvement;
gtree
- https://goframe.org/container/gtree/index
- Simplified tree usage, supporting variable definitions like
var gtree.BTree
; - Enhanced unit tests, code coverage at
90%
;
gvar
- https://goframe.org/container/gvar/index
- Enhanced unit tests, code coverage at
69%
; - Code organization structure adjustment for better maintainability;
- Code refinement, performance improvement;
database
gdb
- Added
Transaction(f func(tx *TX) error) (err error)
interface method for transaction encapsulation using closure: https://goframe.org/database/gdb/transaction - Removed the rarely used
From
interface method, improvedTable
andModel
methods' parameters to variadic, supporting passing table aliases via variadic parameters: https://goframe.org/database/gdb/model/select - Added
DryRun
feature for executing queries without performing insert/update/delete operations: https://goframe.org/database/gdb/senior - Added automatic field population features for
create_at
,update_at
timestamp fields: https://goframe.org/database/gdb/model/auto-time - Added
delete_at
soft delete feature: https://goframe.org/database/gdb/model/auto-time - Added
Having
chain operation method forhaving
condition queries: https://goframe.org/database/gdb/model/select Result
object addedChunk
method for custom batch data processing: https://goframe.org/database/gdb/result- Improved runtime database switching feature of
Schema
; - Enhanced support for field types in
pgsql
,mssql
,sqlite
,oracle
databases; - Further improved unit tests;
- Code organization structure adjustment for better maintainability;
- Code refinement, performance improvement;
- Added
gredis
- Added default configuration for
MaxActive
connection pool parameter to100
to limit the default number of connections; - Improved
Conn
object'sDo
method to support automaticjson.Marshal
formap/slice/struct
types, useDoVar
method to retrieve data: https://goframe.org/database/gredis/usage - Enhanced unit tests, code coverage at
72%
;
- Added default configuration for
net
-
ghttp
- Added
Prefix
andRetry
client chain operation methods; - Added client raw request printing feature: https://goframe.org/net/ghttp/client/demo/dump
- Added
ClientMaxBodySize
server configuration to limit the client's submittedBody
size, default is8MB
; increase this configuration size in servers involving upload, specify the size in the configuration file, e.g.,ClientMaxBodySize="100MB"
: https://goframe.org/net/ghttp/config - Improved randomness of
SessionId
generation, enhancingSession
security: https://goframe.org/os/gsession/index ghttp.Server
now implements the standard library'shttp.Handler
interface, facilitating code integration with third-party services likePrometheus
;- Numerous code detail improvements for performance and long-term maintainability;
- Enhanced unit tests, code coverage at
61%
;
- Added
-
gipv4
- Added
GetIpArray
method for retrieving all current host IPv4 addresses; - Added
GetMacArray
andGetMac
methods for obtaining current host'sMAC
address information; - Changed
IntranetIP
method name toGetIntranetIp
, changedIntranetIPArray
method name toGetIntranetIpArray
;
- Added
encoding
gjson
- Added
GetMaps
method to retrieveJSON
internal node variable; - Improved
NewWithTag
method to handlemap/struct
; - Enhanced unit tests, code coverage at
77%
;
- Added
gyaml
- Upgraded the dependent third-party
yaml
parsing package, addressing themap[interface{}]interface{}
conversion issue;
- Upgraded the dependent third-party
error
gerror
- Added
NewfSkip
method for creating error objects with specified stack skip; - Enabled stack trace printing throughout the framework to show real link call details when errors occur;
- Added
os
-
gcache
- Added
GetVar
method for obtaining "generic" variables easily convertible to other data types; - Deprecated
Removes
method, improvedRemove
method to variadic parameters, unified usage for removing one/multiple key-value pairs; - Enhanced unit tests, code coverage at
96%
;
- Added
-
genv
- Added
GetVar
method for obtaining "generic" variables easily convertible to other data types;
- Added
-
gfile
- Improved
CopyDir/CopyFile
methods; - Added
ScanDirFunc
method for directory retrieval with custom processing callback support; - Enhanced unit tests, code coverage at
64%
;
- Improved
-
glog
- Added logging feature supporting
Context
context variables: https://goframe.org/os/glog/context
- Added logging feature supporting
-
gres
- Improved packaging feature, enhancing compression ratio of generated binary and Go files by 20%, making the compiled binaries smaller;
- Code structure improvement, enhancing execution efficiency and maintainability;
-
gsession
- Improved default
SessionId
generation method usingguid.S
; - Added
SetId
andSetIdFunc
methods for customSessionId
generation methods;
- Improved default
frame
g
- Added
g.Table
method for quickly creating database model operation objects;
- Added
i18n
gi18n
- Added
GetContent
method for obtaining localized content for specifiedi18n
keywords; - Code detail improvements for increased performance and maintainability;
- Enhanced unit tests, code coverage at
74%
;
- Added
test
gtest
- Added
AssertNQ
assertion method for strict type inequality checks;
- Added
text
gstr
- Added
SubStrRune
method for string clipping withunicode
support; - Added
StrLimitRune
method for string truncation hiding withunicode
support; - Added
LenRune
method, replacingRuneLen
, unifying method naming convention; - Added
PosRune/PosIRune/PosRRune/PosRIRune
methods for left-right position searches withunicode
support; - Added
CompareVersionGo
method for Go-style version number comparison; - Enhanced unit tests, code coverage at
75%
;
- Added
util
-
gconv
- Improved
Convert
method, supporting commonmap
type conversion; - Enhanced error handling during type conversion, returning via
error
; - Various detail improvements;
- Enhanced unit tests, code coverage at
63%
;
- Improved
-
grand
- Added
B
method for obtaining random binary data; - Improved underlying implementation, boosting performance of some interfaces by
50%
; - Enhanced unit tests, code coverage at
74%
;
- Added
-
guid
- Added
guid
module for efficient, lightweight unique string generation: https://goframe.org/util/guid/index
- Added
-
gutil
- Added
MapContains
method for checking if a map contains a specified key; - Added
MapDelete
method for deleting specified keys in a map, accepting multiple key names; - Added
MapMerge
method for merging two maps; - Added
MapMergeCopy
method for copying multiple maps; - Added
MapContainsPossibleKey
method for finding a specified key, ignoring cases and characters'-'/'_'/'.'/' '
;
- Added
-
gvalid
- All default error messages have been changed to English;
- Error message configuration is now implemented via
i18n
to support internationalization: https://goframe.org/util/gvalid/message - Renamed ID number rule from
id-number
toresident-id
; - Renamed bank card rule from
luhn
tobank-card
; - Enhanced unit tests, code coverage at
96%
;
Bug Fix
- Fixed multi-file
zip
compression issue ingcompress
; - Fixed issue with
ghttp.Client
retrieving expiredCookie
; - Fixed implementation detail of
http.File
interface ingres.File
; - Fixed boundary issue in
garray.Pop*
methods; - Fixed issue with
gres
methodReaddir
reporting an error when parameter is0
; - Other fixes: https://github.com/gogf/gf/issues?q=is%3Aissue+label%3Abug