GoFrame
GoFrame is a modular, high-performance, production-grade Go foundational development framework. It implements comprehensive infrastructure and development toolchains, offering common foundational development modules such as cache, logging, queues, arrays, collections, containers, timers, command lines, memory locks, object pools, configuration management, resource management, data validation, data encoding, scheduled tasks, database ORM, TCP/UDP components, process management/communication, etc. It also provides a series of core components for Web service development, such as Router, Cookie, Session, Middleware, service registration, template engine, etc., supporting features like hot restart, hot updates, domain binding, TLS/HTTPS, Rewrite, etc.
Features
- Modular and loosely-coupled design;
- Rich modules, ready to use;
- Simple and easy to use, easy to maintain;
- High code quality, high unit test coverage;
- Active community, with humble and approachable experts;
- Detailed development documentation and examples;
- Comprehensive local Chinese support;
- Designed for team and enterprise use;
Support Us
The OSC Best Open Source Project competition has begun. If you like GoFrame, please cast your valuable vote for GoFrame 🙏 https://www.oschina.net/p/goframe
Change Log
Since GoFrame is designed modularly, the update log for each version is introduced in the form of modules.
Important updates:
- Replaced all
jsonoperations within the framework from the standard library tojson-iterator/go, improving operational efficiency. - Refactored the underlying design of the cache module, adding adapter design patterns, and adding memory and
Redisadapter support. The memory adapter is provided by the default core module, while theRedisadapter is provided by the community module: https://goframe.org/os/gcache/adapter - Added customizable validation rule registration feature: https://goframe.org/util/gvalid/customrule
Web Serveradded examples for all configuration items: https://goframe.org/net/ghttp/config/exampleORMaddedSQLcache adapter based onRedis: https://goframe.org/database/gdb/model/cacheORMadded experimental feature for model associations: https://goframe.org/database/gdb/model/association- Improved automatic update feature of time in
ORM, adding customizable time fields: https://goframe.org/database/gdb/model/auto-time - Error handling module added
CurrentandNextmethods: https://goframe.org/errors/gerror/index
net
ghttpClient- Added
GetVar/PutVar/PostVarrequests methods, which allow sendingHTTPrequests and directly returning generic objects for convenient type conversion, making handling of returnedXML/JSONresults simpler: https://goframe.org/net/ghttp/client/demo/index - Added
SetProxy/Proxymethods to set client proxy, supportingHTTP/Socket5proxy types: https://goframe.org/net/ghttp/client/demo/proxy - Added
SetRedirectLimit/RedirectLimitmethods to set page redirect limit.
- Added
Request- Added
ParseQuery,ParseFormmethods to parse specified parameter types and bind them to a given object. - Added
GetHeadermethod to get specifiedHeaderparameters. - Added
GetRemoteIpmethod to get the IP of the requesting client. When using IP whitelist restrictions, useGetRemoteIpinstead ofGetClientIp, as the latter can be forged throughHeader. - Added
ReloadParammethod, often used in middleware processing when middleware modifies request parameters and calls this method to reparse them. - Added
GetRouterMapmethod to get all routing parameters returned as amap.
- Added
Response- Renamed
Outputmethod toFlush, used for writing buffer data to the client stream.
- Renamed
ServerServeradded examples for all configuration items: https://goframe.org/net/ghttp/config/example- Added
SessionCookieOutputconfiguration to control whether to outputSessionIdtoCookie, enabled by default. - Improved route parsing to support
URIwith repeated/symbols. Pproffunction routes supportDomainbinding.- Other minor improvements.
Cookie- Added
SetHttpCookiemethod to setCookiebased on a standard libraryhttp.Cookieobject. - Other functional improvements.
- Added
database
-
gdb- Added experimental feature for model associations: https://goframe.org/database/gdb/model/association
- Improved automatic update feature of time, adding customizable time fields: https://goframe.org/database/gdb/model/auto-time
- Added
SQLcache adapter based onRedis: https://goframe.org/database/gdb/model/cache - Added automatic recognition mapping feature for input parameter key names and field names: https://goframe.org/database/gdb/senior
- Added
DB.HasTablemethod to determine whether the current database contains the specified table. - Added
Model.HasFieldmethod to determine whether the current table contains the specified field. - Added
Model.ScanListmethod to intelligently bind the currentstruct/sliceto the specifiedlistcorresponding attributes. - Added
Result.MapKeyValuemethod to convert the currentResulttomap[string]Valuetype. - Added
Result.IsEmpty/Len/Size/ScanListmethods. - Added
ListItemValuesandListItemValuesUniquemethods to automatically get the values or properties with specified names in thelist, returning them as aslice. SQLlog content includes group name printing.- Improved
DataToMapDeepmethod. - Other minor improvements.
-
gredis- Added
TLSfeature support and configuration file support, https://goframe.org/database/gredis/config
- Added
container
gvar- Added
ScanandScanDeepmethods for automatic recognition and conversion ofstruct/slice. - Added
ListItemValuesandListItemValuesUniquemethods to automatically get the values or properties with specified names in thelist, returning them as aslice. - Added
MapStrAnyinterface implementation method.
- Added
os
-
gcache- Added
GetVarmethod to get cached data and return it as a generic object. - Added
Updatemethod to only modify cache values without modifying expiration times. - Added
UpdateExpiremethod to only modify cache expiration times without modifying values. - Refactored underlying design, adding adapter design patterns, and memory and
Redisadapter support. The memory adapter is provided by the default core module, and theRedisadapter is provided by the community module: https://goframe.org/os/gcache/adapter - Note, this module modification may have some method incompatibility, some methods added
errorparameter return, please review carefully when upgrading. Compilation will not pass. - Other functional improvements.
- Added
-
gfile- Added
ScanDirFileFuncmethod for recursive directory file traversal with a custom function handler. - Improved
Scan*methods with added recursion level limits, default is100000.
- Added
-
gfsnotify- Removed
Watcherobject creation during module initialization, adjusted to runtime on-demand creation, with added concurrency safety controls.
- Removed
-
grpool- Added
AddWithRecovermethod for adding asynchronous tasks with a givenrecoverhandling method, processingpanicin tasks to prevent the entire process crash. - Solves the issue that
recovercan only capturepanicin the currentgoroutine, therefore a specificrecoverhandling method can only be specified when creating asynchronous tasks.
- Added
-
gtime- Added
ParseDurationmethod with support for time unitdrepresenting days. - Improved `` method with support to create
gtime.Timeobjects from strings, timestamps,time.Timeobjects, https://goframe.org/os/gtime/time - Improved
Add/AddStr/ToLocation/ToZone/UTCLocal/AddDate/Truncate/Roundmethods, these methods now create and return newgtime.Timeobjects without altering the current object itself to ensure consistency with the standard librarytime.Timelogic and avoid confusion. - Other minor improvements.
- Added
-
gtimer- Added
Resetmethod for resetting timer task counts.
- Added
-
gfcache- Removed the module, as its functionality was not particularly significant.
debug
gdebug- Added
GoroutineIdmethod to get thegoroutine idof the current execution, for debugging purposes only.
- Added
encoding
-
gjson- Added
GetScan/GetScanDeepmethods. - Added
ToScan/ToScanDeepmethods. - Added
LoadContentTypemethod to createJsonoperation objects based on specified content types. - Added
IsValidDataTypemethod to determine if a given data type is parseable. - Other improvements.
- Comprehensive unit testing.
- Added
-
gcompress- Added
GzipFile/UnGzipFilemethods based ongzipcompression algorithm for file compression/decompression.
- Added
i18n
gi18n- Added
TranslateFormat/TranslateFormatLang/Tf/Tflmethods: https://goframe.org/i18n/gi18n/index
- Added
text
gstr- Added
SnakeFirstUpperCasemethod, which adds connectors before uppercase letters and does not process numbers, e.g.,SnakeFirstUpperCase("RGBCodeMd5")will returnrgb_code_md5.
- Added
util
-
gconv- Added support for basic pointer type conversion.
- Added
Scan/ScanDeepmethods for automatic recognition and conversion ofStruct/[]Struct. - Improved recursive layer handling in
MapDeepmethod. - Other minor and performance improvements.
-
gutil- Added
ListItemValuesandListItemValuesUniquemethods to automatically get values or properties with specified names in thelist, returning them as aslice. - Added
ItemValuemethod to get key/property values of specifiedmap/*map/struct/*structtypes. - Added
MapOmitEmptymethod to filter empty values in amap. - Added
SliceDeletemethod for array item deletion. - Added
Trymethod, which executes a given method through a closure and returnserrorif the methodpanic, otherwise returnsnil. - Improved
TryCatch(try func(), catch ...func(exception interface{}))toTryCatch(try func(), catch ...func(exception error))
- Added
-
gvalid- Added custom rule feature, allowing developers to register custom validation rules: https://goframe.org/util/gvalid/customrule
- Other functional improvements.
error
gerror- Added
Currentmethod to get theerrorinterface object of the current error level. - Added
Nextmethod to get the next level errorerrorinterface object. If the next level does not exist, returnsnil. - Documentation update: https://goframe.org/errors/gerror/index
- Added
Bug Fix
- Fixed
Uniquemethod issue ingarraymodule. - Fixed
goroutineleak issue inglogduring lazy initialization of the timer. - Fixed naming
Caseconversion issues ingstrwhen names contain numbers and special characters. - Fixed
CORScross-domain settingHeaderdetail issue inghttpmodule. - Other BUG fixes: https://github.com/gogf/gf/issues?q=is%3Aissue+label%3Abug+is%3Aclosed