Main Content
GoFrame v2.9 brings several important features and improvements, including ORM database and table sharding, transaction propagation & isolation level control, OpenAPIv3.1 support, gzip middleware, and the new Converter type conversion interface. These new features significantly enhance the framework's performance, scalability, and development experience.
The following are the main contents of this version. For detailed Change Log, please refer to:
https://github.com/gogf/gf/releases/tag/v2.9.0
For complete code changes, please refer to: https://github.com/gogf/gf/compare/v2.8.0...v2.9.0
Special Thanks
💖💖💖 Thanks to all developers who contributed to this version 💖💖💖

Compatibility Notes
-
net/client- When the global service registration and discovery component is enabled, the
HTTP Clientobjects created by this component no longer enable service discovery by default. Manual activation is required.
- When the global service registration and discovery component is enabled, the
-
os/glog- The default time printing format for logs has been adjusted to the more rigorous
2006-01-02T15:04:05.000Z07:00.
- The default time printing format for logs has been adjusted to the more rigorous
Component Improvements
-
database/gdb- Added ORM database and table sharding features, supporting horizontal table sharding and vertical database sharding, greatly enhancing large-scale data processing capabilities: ORM Database and Table Sharding
- Added ORM transaction propagation features, supporting transaction propagation behaviors similar to
Spring, providing more flexible transaction management: ORM Transaction Processing - Transaction Propagation - Added ORM transaction isolation levels, supporting standard SQL transaction isolation level settings: ORM Transaction Processing - Isolation Levels
- Added ORM transaction read-only mode, optimizing read-only transaction performance: ORM Transaction Processing - Read-Only Mode
- Added
WhereExists/WhereNotExistsmethod support, enhancing subquery capabilities: ORM Query - Where Conditions - Added support for
unix socketdatabase connection configuration, providing more connection options. - Fixed an issue where using
gdb.Countertype in theOnDuplicatemethod was ineffective: ORM Chain Operation - Write and Save - Fixed an issue where when users add a
Select Hookand modify the return structure, it causes abnormal query results inCount/Value/Arrayin some scenarios. - Fixed an issue where the
ormtag in the metadata tag ofembedded structin the data structure becomes ineffective when using thewithfeature. - Fixed an incompatibility issue with older versions where
tinyint(1)/int(1)types are identified asbooltype. - Fixed an incompatibility issue with older versions in the
Order("id", "desc")statement in thedatabase/gdbcomponent. - Optimized
ORMquery performance and memory usage efficiency.
-
net/ghttp- Added common middleware
MiddlewareGzipsupport for compressing return results using thegzipalgorithm, improving transmission efficiency and performance. - Added
HandlerItemParsed.GetMetaTagmethod, which can be used to get the interface definition metadata information through theGetMetaTagmethod after getting the current route execution method throughGetServeHandler, enhancing route metadata management capabilities. - Removed the
*Req/*Resnaming rule restriction for input and output data structures when definingapiin standard route registration, supporting more flexible naming methods. - Fixed an issue where the default value setting for interface parameters also takes effect when submitting empty parameters (empty string or
0), causing inconsistency with the document description. - Fixed an issue where the logic of automatically generating
OriginfromRefererin cross-domain returnHeaderis not rigorous, enhancingCORSsecurity. - Fixed an issue where the
json omitemptytag is ineffective when theBuildParamsmethod builds request parameters. - Fixed a null pointer
panicissue that would occur whenLoggeris set tonil, improving component stability.
- Added common middleware
-
util/gconv- Added
Converterconversion interface feature, supporting more flexible and extensible type conversion capabilities, providing a custom type conversion registration mechanism: Type Conversion - Converter - Added custom type conversion support, allowing developers to register custom type conversion functions: Type Conversion - Custom Type Conversion
- Improved the
Scanmethod, adding support forScanto basic data type conversion: Type Conversion - Scan Conversion - Optimized type conversion performance, improving large data volume conversion efficiency.
- Added
-
net/goai- Support for the latest
OpenAPIv3.1protocol specification, maintaining compatibility with mainstream API documentation tools. - Added return data structure extension capability, supporting more flexible response definitions: API Documentation - Extending Response
- Added automatic recognition of data validation rules
min/max/length/min-length/max-length/betweenas corresponding validation data structures inOpenAPIv3, simplifying document generation: API Documentation - OpenAPIv3 - Fixed an issue where the
embedded structdata structure in parameter data structures cannot be expanded into parameter structures, improving complex data structure support. - Optimized document generation performance and memory usage.
- Support for the latest
-
net/client- When the global service registration and discovery component is enabled, the
HTTP Clientobjects created by this component no longer enable service discovery by default and need to be manually enabled: Service Registration and Discovery
- When the global service registration and discovery component is enabled, the
-
os/gcache- Fixed an issue where the data type returned by the
Removemethod in the component is incompatible with older versions.
- Fixed an issue where the data type returned by the
-
errors/gerror- Added
Asmethod support, maintaining compatibility with the standard library: Error Handling - Error Comparison
- Added
-
utils/gvalid- Fixed an issue where
enumsvalidation becomes ineffective when using pointers withenumsparameters. - Fixed an issue of excessive memory usage caused by large binary content
[]bytein parameter validation.
- Fixed an issue where
-
os/glog- The default time printing format for logs has been adjusted to the more rigorous
2006-01-02T15:04:05.000Z07:00.
- The default time printing format for logs has been adjusted to the more rigorous
-
os/gsession- Added
RegenerateId/MustRegenerateIdmethod support for manually regeneratingSession IDto prevent session fixation attacks: Session - RegenerateId
- Added
-
os/gview- Fixed an issue where template files could not be read from the resource manager in some scenarios.
-
os/gcmd- Command line parameter default values now support output to the command help interface.
-
net/gipv4- Improved the implementation logic for converting between
ipaddresses anduint32.
- Improved the implementation logic for converting between
-
test/gtest- Improved
AssertNI/AssertINmethods, addingmaptype support: Unit Testing - gtest
- Improved
Community Components
-
contrib/drivers/pgsql- Added conversion support for
pgsqlarray field typesvarchar[]/text[], automatically converting to Go[]stringtype. - Improved array type conversion performance.
- Added conversion support for
-
contrib/config/polaris- Added support for more data format contents, supporting formats such as
yaml/toml/json/xml/ini/properties.
- Added support for more data format contents, supporting formats such as
-
contrib/registry/consul- Added
consulservice registration and discovery component support: https://github.com/gogf/gf/tree/master/contrib/registry/consul
- Added
-
contrib/registry/etcd- Added retry mechanism, solving the renewal problem when the
leaselease expires. - Removed the default
AutoSyncIntervalconfiguration item, solving theetcdblocking problem caused by this default configuration in some scenarios.
- Added retry mechanism, solving the renewal problem when the
-
contrib/registry/zookeeper- Fixed an error in the component where service name paths with additional suffix
-were incorrectly monitored.
- Fixed an error in the component where service name paths with additional suffix
-
contrib/config/nacos- Added
OnChangecallback configuration support.
- Added
-
contrib/metric/otelmetric- Added
WithExemplarFilteroption support.
- Added
Development Tools
- Improved the
gf initcommand, changing the template content for initializing projects, with no change in directory structure. - Improved the
gf upcommand, displaying a more elegantclifile download interface effect in the terminal, enhancing user experience. - Improved the
gf gen ctrlcommand, automatically synchronizing comments defined inapito the generated controller code, reducing duplicate work. - Improved the
gf gen daocommand:- Added sharding option parameter
shardingPattern/spfor defining table sharding rules, generatingdaocode that supports database sharding, working with ORM database sharding features: Data Specification - gen dao - Improved code generation templates, supporting
Golang Templatesyntax, providing more flexible code generation capabilities. - Optimized the quality and readability of generated code.
- Added sharding option parameter
- Improved the
gf gen enumscommand:- Changed the default interface data structure definition directory to
api, more in line with project specifications. - Changed the default generated code file path to
internal/packed/packed_enums.go, optimizing code organization.
- Changed the default interface data structure definition directory to
- Improved the
gf gen genpbentitycommand:- Added
TypeMappingandFieldMappingfeature support, providing more flexible type mapping: Database Table PB - gen pbentity - Added
TablesExsupport, allowing specific tables to be ignored when generatingprotofiles, increasing flexibility. - Added the
GoPackageoption for specifying thego_packageconfiguration item in generatedprotofiles, better supporting modularization.
- Added
- Fixed an issue with the
gf buildcommand where environment variables were not accurately printed; it should print the actual environment variables used when compiling files after modifying environment variables. - Fixed an issue with the
gf gen pbcommand where custom tags were repeatedly added after multiple executions of the command with the-aoption in some scenarios. - Fixed an issue in the
cmd/gfcomponent where commands in theMakefilefile generated in the project template by themakecommand were incorrect. - Overall improvement in command line tool usability and stability.