Hello everyone! This version is the last one for the year 2022 and the first one for 2023. The main goals of this version are:
- Using an interface design to solve the coupling issue of the main framework with the third-party open-source component
go-redis, making the main framework lighter and more friendly for tool-based usage scenarios. - Providing upgrade commands for the main framework, community components, and development tools via development tools, improving the overall usability of the framework and addressing the common issue of version inconsistency between community components and the main framework.
- Further designing according to the separation of interfaces and implementations, enhancing the integration of registration discovery and configuration management for common services through community components, preparing for the subsequent release of microservice components.
Complete change list: https://github.com/gogf/gf/compare/v2.2.0...v2.3.1
New Features
- The heavily coupled
rediscomponent is decoupled from the main framework and provided as a community component. The main framework adds aredisinterface definition, while the community componentredisprovides a concrete implementation. Therefore, please note that the usage of the main framework'sgrediscomponent has changed, and in projects relying onredis, it is necessary to introduce the community componentredisimplementation, otherwise method execution will return an error. The originalDo/DoVarmethods are retained for compatibility, and more than100commonly usedredisoperation methods are added: NoSQL Redis - New common service interface implementations for configuration management and registration discovery components:
- Configuration Management (
nacos): https://github.com/gogf/gf/tree/master/contrib/config/nacos - Registration Discovery (
zookeeper): https://github.com/gogf/gf/tree/master/contrib/registry/zookeeper
- Configuration Management (
- Added tool command
gf upfor convenient framework upgrades, see: Version Upgrade
Improvements
Community Components
Configuration Management
- Added
nacosinterface implementation: https://github.com/gogf/gf/tree/master/contrib/config/nacos
Registration Discovery
- Added
zookeeperinterface implementation: https://github.com/gogf/gf/tree/master/contrib/registry/zookeeper
Database Driver
- Fixed the error issue when configuring the
Charsetparameter forclickhouse. - Improved the retrieval of data table structure results for
clickhouse, with the returnedIndexorder consistently starting from0. - Improved the
oracletable structure retrieval SQL to support thefloat64data type. - Fixed the implementation of the
CheckLocalTypeForFieldinterface forpgsql, where the name was incorrectly defined asCheckLocalTypeForValue, causing attribute field type errors when generatingdaocode files. - Improved
pgsqlto add support forschema. Sinceschemarepresents "database name" in most database services, and to maintain backward compatibility, aNamespaceconfiguration parameter is added to representpgsql'sSchema, while the originalSchemaobject representspgsql'scatalog.
NoSQL Components
- Added
rediscommunity component to implementgredisrelated interfaces: https://github.com/gogf/gf/tree/master/contrib/nosql/redis
Database Components
gdb- To enhance extensibility, the
TXtransaction object is changed to an interface definition, and the originalTXobject is renamed toTXCorefor convenient custom interface implementation object nesting: ORM - Transaction - Added
Namespaceconfiguration item to support issues of distinguishingCatalog&Schemain some database services. The originalSchemacontinues to represent the database name, while the newNamespacerepresents theSchemaconfiguration in some database services: ORM - Configuration - Improved database name configuration to support Chinese database names.
- Added the current database name printout in the
SQLexecution log. - Fixed the cache issue of the
Countmethod. gredis- Added
rediscommunity component to decouple the heavily coupledrediscomponent from the main framework, and provide it as a community component. The main framework adds aredisinterface definition, and the community componentredisprovides a concrete implementation. Therefore, please note that the usage of the main framework'sgrediscomponent has changed, and in projects relying onredis, it is necessary to introduce the community componentredisimplementation, otherwise method execution will return an error. The originalDo/DoVarmethods are retained for compatibility, and more than100commonly usedredisoperation methods are added: NoSQL Redis
Container Components
gpool- Added the
MustPutmethod to directlypanicinstead of returning an error object whenPutexecution errors occur. gqueue- Improved the
Len/Sizemethods to resolve potential queue count inaccuracies. - Improved the
Len/Sizemethods, with the return parameter type changed frominttoint64.
Error Handling
gcode- Added
CodeNecessaryPackageNotImporterror code. gerror- Improved stack prints, using spaces to replace
\tto ensure the print format is compatible with different display terminals.
Object Management
gins- Added group lock mechanism for singleton objects to enhance lock mechanism performance under high concurrency.
Network Components
ghttp- Support for obtaining the current execution route method in middleware.
- When the execution result of the route method is not
200, support obtaining internal errors through theRequest.GetErrormethod in middleware. - Added
Response.ServeContentmethod for custom content output interface implementation. - Improved reverse proxy support and added reverse proxy example: https://github.com/gogf/gf/blob/master/example/httpserver/proxy/main.go
- Improved error log output, using the
errorlog level, making it easier for developers to identify log types in custom logHandlers. goai- Added support for the
securitytag to configureOpenAPIv3security keys. - Improved structure attribute name retrieval when the
jsontag contains,. gtcp- Renamed
SetSendDeadlinemethod toSetDeadlineSend. - Renamed
SetReceiveDeadlinemethod toSetDeadlineRecv. - Renamed
SetReceiveBufferWaitmethod toSetBufferWaitRecv. gudp- Renamed
SetSendDeadlinemethod toSetDeadlineSend. - Renamed
SetReceiveDeadlinemethod toSetDeadlineRecv. - Renamed
SetReceiveBufferWaitmethod toSetBufferWaitRecv.
System Components
gcache- Fixed the
MustGetOrSetFuncmethod logic issue. - Improved the
LRUcache expiration recycling mechanism implementation. gcmd- Improved structured command line object generation, automatically reading
dctag content asbriefwhen thebrieftag is empty, ensuring that command line and interface definition tag habits are the same. gcron- Improved log handling, using
glog.DefaultLoggerto output error logs when a scheduled task methodpanicoccurs and the developer hasn't set theLoggerinterface. - Improved scheduled trigger judgment logic, resolving scheduled task triggering issues caused by inaccurate execution intervals of the underlying timer.
glog- Improved initialization logic when rolling split feature is enabled, resolving failure of rolling split execution due to initialization failure in some scenarios.
- Improved the
Clonemethod for further shallow copying to enhance chain operation performance. - Added
LevelPrintconfiguration to control whether the default logHandlerprints the log level string. gres- Added
Pack*WithOptionmethods to provide finer-grained resource packaging option control. - Deprecated methods:
Pack/PackToFile/PackToGoFile. - Added
KeepPathpackaging option to control whether to retain the given relative path in the packaged file instead of using a path with a local packaging directory prefix (equivalent to removing the directory prefix). grpool- Added
supervisorfeature to solve the issue of low probability of quitting at the same time in scenarios with a small number ofworkers. gstructs- Added
Tag*methods to obtain common tag values. gtime- Improved
Equal/After/Submethods to resolve detailed issues in some scenarios. - Improved
EndOf*methods, allowing developers to control the granularity ofEndOfcalculation in the returned time object. The default granularity is changed from nanoseconds to seconds for calculation. - Improved the
SetTimeZonemethod to achieve cross-system compatibility, allowing only a global setting of the time zone once, with errors returned for multiple calls with different time zones: Time - Time Zone
Text Processing
gstr- Fixed
IsSubDomainissue of determining that the main domain is a subdomain of a subdomain. - Improved
SubStr/SubStrRunemethods to support the use of a negativestartparameter to specify right-side substring extraction.
Utility Components
gconv- Added
Ptr*methods for arbitrary type to specific type pointer variable conversion. - Improved
Map*conversion methods for handling recursive conversions, by default, only recursively converting nested structure attributes. - Improved
Scanmethod to resolve conversion issues from attributes of the same type and the same type pointer to target object/pointer. gtag- Unified all tag names in the framework to be maintained under this module through constants.
- Added
SetOver/SetsOvermethods for overriding custom tag key-value pairs. gutil- Improved
Dump*methods to support printing of circular nested object pointers. - Fixed
Dump*method reflection error issues in some scenarios. - Added
OriginValueAndKind/OriginTypeAndKindmethods to obtain the reflect value/type object of a given variable, as well as the original reflect value/type object under pointer variables.
Bug Fixes
- Fixed the issue of utility installation failure in some environments.
- Fixed array boundary issue in
New*ArrayRangemethod for array object creation in some scenarios. - Fixed the error issue when configuring the
Charsetparameter forcontrib/drivers/clickhouse. - Fixed attribute field type error issue in
pgsqldatabase generateddaocode files. - Fixed cache issue with the
Countmethod in the database ORM component. - Fixed
gstr.IsSubDomainissue of determining that the main domain is a subdomain of a subdomain. - Fixed
gutil.Dump*method reflection error issues in some scenarios.
Development Tools
- Added
gf fixcommand for automatically updating local code incompatible changes when upgrading from lower to higher versions: Compatibility Fix - Added
gf upcommand to upgrade local framework versions to the latest framework version: Version Upgrade - Improved
gf buildcommand to add environment variable information printing before building. - Improved
gf packcommand to addKeepPathparameter to control whether to keep the relative path after resource packaging: Resource Packing - Improved
gf gen daocommand withtxparameter in generatedTransactionmethods changed from object pointer to interface.
Compatibility Warning
- The usage of
Redishas changed. The old methods remain compatible, but additional community components need to be imported (interface and implementation separation). Please see the documentation for details. - The
TXobject of the databaseORMis changed from a concrete implementation to an interface. This can be automatically upgraded and fixed using the newuporfixcommand in the development tools.
Next Version Goals
- Improve and release the
grpcxcommunity component to provide extended support for thegrpcinterface protocol and enhance the usability of microservice development. - Add a [Microservice Development] series chapter on the official website, mainly introducing microservice development using
goframewith a focus ongrpcdevelopment. - Remove coupling with the third-party open-source component
gorilla/websocketin the main framework, interface the support ofWebSocket, and provide concrete implementations through community components according to the general decoupling design of the framework, providing extensibility and flexibility.