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
Golangruntime version required by the framework has been downgraded tov1.11. - Added new
GoFramevideo tutorial addresses:- bilibili: https://www.bilibili.com/video/av94410029
- Xigua Video: https://www.ixigua.com/pseries/6809291194665796100/
- The rarely-used
guuidmodule has been moved to github.com/gogf/guuid as a community-maintained module, keeping the maingfrepository lightweight. - Added
guidmodule for efficient, lightweight unique string generation: https://goframe.org/util/guid/index
tool chain
- Toolchain update: https://goframe.org/toolchain/cli
- Added
gf envcommand for elegantly viewing currentGolangenvironment variable information. - Added
gf mod pathcommand to copy the currentgo modulespackage toGOPATH, facilitating project development using the originalGOPATHmethod. - Made improvements to existing
clicommands, enhancing user experience; precompiled binary versions areupxcompressed 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
Walkmethod for custom array element processing; - Added
ContainsImethod 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
Mapusage, 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
Walkmethod 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
Frominterface method, improvedTableandModelmethods' parameters to variadic, supporting passing table aliases via variadic parameters: https://goframe.org/database/gdb/model/select - Added
DryRunfeature for executing queries without performing insert/update/delete operations: https://goframe.org/database/gdb/senior - Added automatic field population features for
create_at,update_attimestamp fields: https://goframe.org/database/gdb/model/auto-time - Added
delete_atsoft delete feature: https://goframe.org/database/gdb/model/auto-time - Added
Havingchain operation method forhavingcondition queries: https://goframe.org/database/gdb/model/select Resultobject addedChunkmethod 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,oracledatabases; - Further improved unit tests;
- Code organization structure adjustment for better maintainability;
- Code refinement, performance improvement;
- Added
gredis- Added default configuration for
MaxActiveconnection pool parameter to100to limit the default number of connections; - Improved
Connobject'sDomethod to support automaticjson.Marshalformap/slice/structtypes, useDoVarmethod to retrieve data: https://goframe.org/database/gredis/usage - Enhanced unit tests, code coverage at
72%;
- Added default configuration for
net
-
ghttp- Added
PrefixandRetryclient chain operation methods; - Added client raw request printing feature: https://goframe.org/net/ghttp/client/demo/dump
- Added
ClientMaxBodySizeserver configuration to limit the client's submittedBodysize, 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
SessionIdgeneration, enhancingSessionsecurity: https://goframe.org/os/gsession/index ghttp.Servernow implements the standard library'shttp.Handlerinterface, 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
GetIpArraymethod for retrieving all current host IPv4 addresses; - Added
GetMacArrayandGetMacmethods for obtaining current host'sMACaddress information; - Changed
IntranetIPmethod name toGetIntranetIp, changedIntranetIPArraymethod name toGetIntranetIpArray;
- Added
encoding
gjson- Added
GetMapsmethod to retrieveJSONinternal node variable; - Improved
NewWithTagmethod to handlemap/struct; - Enhanced unit tests, code coverage at
77%;
- Added
gyaml- Upgraded the dependent third-party
yamlparsing package, addressing themap[interface{}]interface{}conversion issue;
- Upgraded the dependent third-party
error
gerror- Added
NewfSkipmethod 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
GetVarmethod for obtaining "generic" variables easily convertible to other data types; - Deprecated
Removesmethod, improvedRemovemethod to variadic parameters, unified usage for removing one/multiple key-value pairs; - Enhanced unit tests, code coverage at
96%;
- Added
-
genv- Added
GetVarmethod for obtaining "generic" variables easily convertible to other data types;
- Added
-
gfile- Improved
CopyDir/CopyFilemethods; - Added
ScanDirFuncmethod for directory retrieval with custom processing callback support; - Enhanced unit tests, code coverage at
64%;
- Improved
-
glog- Added logging feature supporting
Contextcontext 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
SessionIdgeneration method usingguid.S; - Added
SetIdandSetIdFuncmethods for customSessionIdgeneration methods;
- Improved default
frame
g- Added
g.Tablemethod for quickly creating database model operation objects;
- Added
i18n
gi18n- Added
GetContentmethod for obtaining localized content for specifiedi18nkeywords; - Code detail improvements for increased performance and maintainability;
- Enhanced unit tests, code coverage at
74%;
- Added
test
gtest- Added
AssertNQassertion method for strict type inequality checks;
- Added
text
gstr- Added
SubStrRunemethod for string clipping withunicodesupport; - Added
StrLimitRunemethod for string truncation hiding withunicodesupport; - Added
LenRunemethod, replacingRuneLen, unifying method naming convention; - Added
PosRune/PosIRune/PosRRune/PosRIRunemethods for left-right position searches withunicodesupport; - Added
CompareVersionGomethod for Go-style version number comparison; - Enhanced unit tests, code coverage at
75%;
- Added
util
-
gconv- Improved
Convertmethod, supporting commonmaptype conversion; - Enhanced error handling during type conversion, returning via
error; - Various detail improvements;
- Enhanced unit tests, code coverage at
63%;
- Improved
-
grand- Added
Bmethod 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
guidmodule for efficient, lightweight unique string generation: https://goframe.org/util/guid/index
- Added
-
gutil- Added
MapContainsmethod for checking if a map contains a specified key; - Added
MapDeletemethod for deleting specified keys in a map, accepting multiple key names; - Added
MapMergemethod for merging two maps; - Added
MapMergeCopymethod for copying multiple maps; - Added
MapContainsPossibleKeymethod 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
i18nto support internationalization: https://goframe.org/util/gvalid/message - Renamed ID number rule from
id-numbertoresident-id; - Renamed bank card rule from
luhntobank-card; - Enhanced unit tests, code coverage at
96%;
Bug Fix
- Fixed multi-file
zipcompression issue ingcompress; - Fixed issue with
ghttp.Clientretrieving expiredCookie; - Fixed implementation detail of
http.Fileinterface ingres.File; - Fixed boundary issue in
garray.Pop*methods; - Fixed issue with
gresmethodReaddirreporting an error when parameter is0; - Other fixes: https://github.com/gogf/gf/issues?q=is%3Aissue+label%3Abug