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
redis
component is decoupled from the main framework and provided as a community component. The main framework adds aredis
interface definition, while the community componentredis
provides a concrete implementation. Therefore, please note that the usage of the main framework'sgredis
component has changed, and in projects relying onredis
, it is necessary to introduce the community componentredis
implementation, otherwise method execution will return an error. The originalDo/DoVar
methods are retained for compatibility, and more than100
commonly usedredis
operation 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 up
for convenient framework upgrades, see: Version Upgrade
Improvements
Community Components
Configuration Management
- Added
nacos
interface implementation: https://github.com/gogf/gf/tree/master/contrib/config/nacos
Registration Discovery
- Added
zookeeper
interface implementation: https://github.com/gogf/gf/tree/master/contrib/registry/zookeeper
Database Driver
- Fixed the error issue when configuring the
Charset
parameter forclickhouse
. - Improved the retrieval of data table structure results for
clickhouse
, with the returnedIndex
order consistently starting from0
. - Improved the
oracle
table structure retrieval SQL to support thefloat64
data type. - Fixed the implementation of the
CheckLocalTypeForField
interface forpgsql
, where the name was incorrectly defined asCheckLocalTypeForValue
, causing attribute field type errors when generatingdao
code files. - Improved
pgsql
to add support forschema
. Sinceschema
represents "database name" in most database services, and to maintain backward compatibility, aNamespace
configuration parameter is added to representpgsql
'sSchema
, while the originalSchema
object representspgsql
'scatalog
.
NoSQL Components
- Added
redis
community component to implementgredis
related interfaces: https://github.com/gogf/gf/tree/master/contrib/nosql/redis
Database Components
gdb
- To enhance extensibility, the
TX
transaction object is changed to an interface definition, and the originalTX
object is renamed toTXCore
for convenient custom interface implementation object nesting: ORM - Transaction - Added
Namespace
configuration item to support issues of distinguishingCatalog&Schema
in some database services. The originalSchema
continues to represent the database name, while the newNamespace
represents theSchema
configuration in some database services: ORM - Configuration - Improved database name configuration to support Chinese database names.
- Added the current database name printout in the
SQL
execution log. - Fixed the cache issue of the
Count
method. gredis
- Added
redis
community component to decouple the heavily coupledredis
component from the main framework, and provide it as a community component. The main framework adds aredis
interface definition, and the community componentredis
provides a concrete implementation. Therefore, please note that the usage of the main framework'sgredis
component has changed, and in projects relying onredis
, it is necessary to introduce the community componentredis
implementation, otherwise method execution will return an error. The originalDo/DoVar
methods are retained for compatibility, and more than100
commonly usedredis
operation methods are added: NoSQL Redis
Container Components
gpool
- Added the
MustPut
method to directlypanic
instead of returning an error object whenPut
execution errors occur. gqueue
- Improved the
Len/Size
methods to resolve potential queue count inaccuracies. - Improved the
Len/Size
methods, with the return parameter type changed fromint
toint64
.
Error Handling
gcode
- Added
CodeNecessaryPackageNotImport
error code. gerror
- Improved stack prints, using spaces to replace
\t
to 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.GetError
method in middleware. - Added
Response.ServeContent
method 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
error
log level, making it easier for developers to identify log types in custom logHandlers
. goai
- Added support for the
security
tag to configureOpenAPIv3
security keys. - Improved structure attribute name retrieval when the
json
tag contains,
. gtcp
- Renamed
SetSendDeadline
method toSetDeadlineSend
. - Renamed
SetReceiveDeadline
method toSetDeadlineRecv
. - Renamed
SetReceiveBufferWait
method toSetBufferWaitRecv
. gudp
- Renamed
SetSendDeadline
method toSetDeadlineSend
. - Renamed
SetReceiveDeadline
method toSetDeadlineRecv
. - Renamed
SetReceiveBufferWait
method toSetBufferWaitRecv
.
System Components
gcache
- Fixed the
MustGetOrSetFunc
method logic issue. - Improved the
LRU
cache expiration recycling mechanism implementation. gcmd
- Improved structured command line object generation, automatically reading
dc
tag content asbrief
when thebrief
tag is empty, ensuring that command line and interface definition tag habits are the same. gcron
- Improved log handling, using
glog.DefaultLogger
to output error logs when a scheduled task methodpanic
occurs and the developer hasn't set theLogger
interface. - 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
Clone
method for further shallow copying to enhance chain operation performance. - Added
LevelPrint
configuration to control whether the default logHandler
prints the log level string. gres
- Added
Pack*WithOption
methods to provide finer-grained resource packaging option control. - Deprecated methods:
Pack/PackToFile/PackToGoFile
. - Added
KeepPath
packaging 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
supervisor
feature 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/Sub
methods to resolve detailed issues in some scenarios. - Improved
EndOf*
methods, allowing developers to control the granularity ofEndOf
calculation in the returned time object. The default granularity is changed from nanoseconds to seconds for calculation. - Improved the
SetTimeZone
method 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
IsSubDomain
issue of determining that the main domain is a subdomain of a subdomain. - Improved
SubStr/SubStrRune
methods to support the use of a negativestart
parameter 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
Scan
method 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/SetsOver
methods 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/OriginTypeAndKind
methods 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*ArrayRange
method for array object creation in some scenarios. - Fixed the error issue when configuring the
Charset
parameter forcontrib/drivers/clickhouse
. - Fixed attribute field type error issue in
pgsql
database generateddao
code files. - Fixed cache issue with the
Count
method in the database ORM component. - Fixed
gstr.IsSubDomain
issue 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 fix
command for automatically updating local code incompatible changes when upgrading from lower to higher versions: Compatibility Fix - Added
gf up
command to upgrade local framework versions to the latest framework version: Version Upgrade - Improved
gf build
command to add environment variable information printing before building. - Improved
gf pack
command to addKeepPath
parameter to control whether to keep the relative path after resource packaging: Resource Packing - Improved
gf gen dao
command withtx
parameter in generatedTransaction
methods changed from object pointer to interface.
Compatibility Warning
- The usage of
Redis
has 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
TX
object of the databaseORM
is changed from a concrete implementation to an interface. This can be automatically upgraded and fixed using the newup
orfix
command in the development tools.
Next Version Goals
- Improve and release the
grpcx
community component to provide extended support for thegrpc
interface protocol and enhance the usability of microservice development. - Add a [Microservice Development] series chapter on the official website, mainly introducing microservice development using
goframe
with a focus ongrpc
development. - Remove coupling with the third-party open-source component
gorilla/websocket
in 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.