👋 Hi, friends! The GoFrame framework v2.2.0 was officially released today!
The major highlights of this version include:
- The validation component, most frequently used by developers, has been restructured and improved, making it easier for community developers to develop and maintain built-in validation rules. It also enhances some common validation rules, making the component's built-in rules richer and stronger.
- The database component interface design has been reconstructed, making it easier for community developers to add a new database type
driver. Currently, the framework provides9types of databasedriverimplementations through community components, meeting the needs of most business projects. Notably, this version adds support for the domestic Dameng Database. We hope that in the future, community developers can provide moredriverimplementations for domestic databases and contribute to the open-source community. - The richness of community components is expanded by adding
3types of configuration center interface implementations in this release, supportingApollo/Polaris/Kubernetes ConfigMap. TheGoFrameframework adopts a modular low-coupling design, with components split into the main framework library and community components. The main framework library provides core, general, and lightweight basic components, while the community components are standalone packages decoupled from the main framework library, expanding the capabilities of the framework while ensuring the core's lightness. - With over
44code contributors in this release, the total number of contributors to the framework has reached107. We appreciate everyone's efforts and contributions to the community! 💖
Github ChangeLog: https://github.com/gogf/gf/releases/tag/v2.2.0
New Features
- Refactored the built-in validation rules manager of the validation component, increasing and supporting
59commonly used built-in validation rules: Data Validation - Rules - Added the community component
contrib/config/kubecm, implementing a configuration componentAdapterbased onkubernetes configmap: https://github.com/gogf/gf/tree/master/contrib/config/kubecm - Added the community component
contrib/config/apollo, implementing a configuration componentAdapterbased on theapolloconfiguration center: https://github.com/gogf/gf/tree/master/contrib/config/apollo - Added the community component
contrib/config/polaris, implementing a configuration componentAdapterbased on thepolarisconfiguration center: https://github.com/gogf/gf/tree/master/contrib/config/polaris - Added
contrib/drivers/dmsupport for the domestic Dameng Database: https://github.com/gogf/gf/tree/master/contrib/drivers
Major Improvements
Community Components
ORM Driver Implementation
- Improved
contrib/drivers/pgsqlto support morepgsqlbuilt-in data types at the ORM component level. - Improved
contrib/drivers/pgsqlto support theLastInsertIdfeature for write operations. - Improved
contrib/drivers/clickhouseto supportdecimal.Decimaldata types. - Added
contrib/drivers/dmsupport for the domestic Dameng Database: https://github.com/gogf/gf/tree/master/contrib/drivers
Service Discovery Components
- Improved the
contrib/registry/etcdimplementation by turning the log object into an interface property, allowing external registration of custom log objects.
Configuration Components
- Added the community component
contrib/config/kubecm, implementing a configuration componentAdapterbased onkubernetes configmap: https://github.com/gogf/gf/tree/master/contrib/config/kubecm - Added the community component
contrib/config/apollo, implementing a configuration componentAdapterbased on theapolloconfiguration center: https://github.com/gogf/gf/tree/master/contrib/config/apollo - Added the community component
contrib/config/polaris, implementing a configuration componentAdapterbased on thepolarisconfiguration center: https://github.com/gogf/gf/tree/master/contrib/config/polaris
Database ORM
- Unified the configuration management format of single-line strings for different database types and maintained compatibility and support for the existing specific configuration formats for different database types: ORM - Configuration
- Improved interface design, simplifying
driverimplementation logic, making it easier to add more databasedriversupport in the future. - Added the
ToSQLmethod to generate SQL statements for debugging ORM operations without actually executing the SQL. - Added the
CatchSQLmethod to obtain a list of internally executed SQL statements through a closure method. - Deprecated the
Coreobject'sGetStruct/GetStructsmethods, opting for a unifiedScanmethod for better usability. - Changed the database object's log object to an interface property, allowing for external registration of custom log objects.
- Added
ExtraandProtocolconfigurations for setting additional configuration parameters and link protocols, with default automatic parsing throughLinkconfiguration. - Removed the
Filteredinterface, adopting a default implementation to simplify complexity and improve usability. - Added
ConvertValueForLocalandCheckLocalTypeForFieldinterfaces for custom data type conversion and fetching, with default implementation provided. - Added
ClearTableFieldsmethod for clearing data structure cache specific to a particular database table: ORM Senior - Field Mapping - Added
ClearTableFieldsAllmethod for clearing all data structure caches for all tables in the current database object: ORM Senior - Field Mapping - Added
ClearCachemethod for clearing all query caches for a particular database table: ORM Model - Query Cache - Added
ClearCacheAllmethod for clearing all query caches for the current database object: ORM Model - Query Cache - Various other improvements.
Encoding and Decoding Component
gcompress- Added
GzipPathWritermethod for compressing files from a specific path into a specifiedio.Writer. - Added
ZipPathContentmethod for packaging and compressing files/directories using thezipalgorithm and returning byte content. gjson- Adjusted
ContentTypeJsonand other string parameters toContentTypetype.
Error Handling
- Added command-line parameter
--gf.gerror.briefandGF_GERROR_BRIEFenvironment variable switch, controlling whether the framework stack is filtered when printing error stacks: Error Handling - Other Features - Various other detail improvements.
Network Component
ghttp- Added commonly used middleware
MiddlewareJsonBodyfor validating whether the requestBodyis inJSONformat. - Added
GetListenedAddressmethod for getting the listening address whenHTTP Serverlistens on the specified:0port, where the system randomly assigns a listening address. - Modified the return HTTP status code to
500when an error occurs on the server side. gtcp- Added
GetListenedAddress/GetListenedPortmethods for obtaining the listening address/port whenTCP Serverlistens on the specified:0port, where the system randomly assigns a listening address/port. gudp- Added
GetListenedAddress/GetListenedPortmethods for obtaining the listening address/port whenUDP Serverlistens on the specified:0port, where the system randomly assigns a listening address/port. goai- Added support for properties defined in embedded structs when generating API documentation.
- Removed duplicate parameter descriptions in the API documentation, especially when identical parameters exist in both
URLandBody. gtrace- Improved the error prompts for the
WithTraceIDmethod with more explicit information. - Added
WithUUIDmethod for converting standardUUIDtoOpenTelemetryTraceID.
System Component
gcfg- Adjusted the
Availableinterface method definition, making theresourceparameter optional. gcron- Added time difference calculation logic for scenarios of job delay, minimizing the impact on scheduled jobs whenever possible.
gctx- Added support for cross-process link tracking.
- Added
GetInitCtx/SetInitCtxmethod for obtaining and setting the context during the execution of themainpackage and packageinitinitialization methods. glog- Added
ILoggerinterface definition for decoupled and interface-based use of log components across components. - Other detail improvements.
gres- Added
Exportmethod to theFileobject, enabling the export of resources associated with this object to a specified disk path. gstructs- Improved
RecursiveOptionfrominttype to a custom type, along with adjustments to the corresponding method parameters.
Text Processing
- Added
gstr.IsGNUVersionmethod for determining whether a given string complies withGNUversion rules.
Utility Methods
gconv- Improved
int64/uint64conversion support for the special stringNaN. gutil- Added
GetOrDefaultStr/GetOrDefaultAnymethods for convenient handling of default values and optional parameters. gvalid- Refactored the built-in validation rules manager, making it very convenient to add a new built-in validation.
- Increased and supported
59commonly used built-in validation rules: Data Validation - Rules
Bug Fixes
- Fixed
panicissue ofDeepCopyingarray/gmap/gset/glist/gtype/gvarwhen the container object isnil. - Fixed
panicissue ofDeepCopyingtimewhen the object isnil. - Fixed the issue of overwriting multiple sort conditions in the
Groupmethod of the ORM chain operation. - Fixed the problem of duplicate output while returning
JSONformat strings inHTTP Server. - Fixed out-of-bounds array access in the
gstr.Nl2Brmethod caused by logical judgment in some scenarios. - Fixed error print issue when table name is empty while fetching database table field information.
- Fixed parameter reception issue of object properties as
*gjson.Jsontype inReq.
Development Tools
- Improved
gen daocommand by adding theclearparameter to automatically clean up local data model Go files that do not exist in the target database: Dao/Do/Entity Generating - Improved
gen servicecommand: Service Generating - Integrated interface generation of struct objects by business module.
- Added
clearparameter to automatically clean up interface code and files not corresponding tologic. - Various other detail improvements.
- Improved
runcommand by adding custom program run parameters.