Hello everyone, the v2.1 release includes some business-related function features, improvements, and bug fixes. It’s recommended to upgrade.

Video Introduction: 2022-06-22 GoFrame v2.1 Features & Q&A

New Features

  1. The development tool introduces the gen service command, supporting automated generation of service interface code and implementation injection based on the logic layer code: Service Generating
  2. Database Features:
  3. Added WhereBuilder feature for more flexible SQL condition statement combinations: Model Query - Where
  4. Added Hook feature for custom hook event handling: ORM Model - Hook
  5. The framework adds a DeepCopy feature for deep copying of types:
  6. Added gutil.Copy method for deep copying specified content.
  7. Generic types add a Copy method for deep copying their own content.
  8. Some data types of the framework now support the deep copy feature, such as basic container types like gvar, garray, gmap.

Major Improvements

Community Components

ORM Driver Implementation

  1. Added drivers/clickhouse for hooking clickhouse to the goframe ORM component.
  2. Complete unit tests for clickhouse/mssql/pgsql/sqlite/oracle components.
  3. Moved the mysql driver from the main library to the community module to facilitate decoupling from the main library. Therefore, from subsequent versions, developers need to manually import driver dependencies: https://github.com/gogf/gf/tree/master/contrib/drivers

Registration Discovery Implementation

  1. Added polaris North Star service registration interface implementation: https://github.com/gogf/gf/tree/master/contrib/registry/polaris
  2. Improved the etcd service registration discovery interface implementation component: https://github.com/gogf/gf/tree/master/contrib/registry/etcd

Registration Discovery

  1. Improved the Service implementation object to an interface definition and provided a default Service implementation for improved extensibility and usability.
  2. Improved HTTP/GRPC Client&Server interface implementations.

Load Balancing

  1. Improved the Node interface definition and added the Nodes interface definition.
  2. Fixed the load balancing issue under the HTTP Client.

Network Components

  1. gclient
  2. Improved service discovery implementation logic.
  3. Fixed client shutdown error causing connection pool reuse issues.
  4. ghttp
  5. Improved Request.GetUrl method details for URL Schema.
  6. Parameter reception supports automatic receipt of UploadFile attributes.
  7. Added custom UI guidance documentation for interface documentation: API Document - Custom UI
  8. Changed the default external JS CDN dependency for interface documentation to unpkg.com.
  9. Improved service registration implementation logic.
  10. Improved internal detail implementation logic.
  11. Fixed the parameter empty judgment issue.
  12. goai
  13. Improved adherence to the OpenAPIV3 protocol implementation.
  14. Supports all custom tags starting with x-, automatically adding them to the OpenAPIV3 results.
  15. The component moved from the protocol category to the net category, changing the import path.

System Components

  1. gcfg
  2. The default file system interface implements support for the property file format.
  3. gcmd
  4. Parameter parsing adds CaseSensitive configuration, default parsing is case-insensitive, especially affecting structured parameter reception: Command - Structure
  5. Added cross-process link tracking feature: Command - Tracing
  6. glog
  7. Added a global Handler setting function, allowing developers to globally customize handling of all logs of the glog component, such as globally outputting in the JSON file format: Logging - Handler
  8. Added the default JSON format Handler for developers to use: Logging - Handler
  9. gsession
  10. Resolved excessive memory usage issues caused by too many user accesses.
  11. gproc
  12. Added cross-process link tracking feature: Process - Tracing

Container Components

  1. garray
  2. Improved the Unique method performance, added DeepCopy interface implementation.
  3. glist
  4. Added DeepCopy interface implementation.
  5. gmap
  6. Added DeepCopy interface implementation.
  7. gset
  8. Added DeepCopy interface implementation.
  9. gtype
  10. Added DeepCopy interface implementation.
  11. gvar
  12. Added Copy method for deep copying the current generic object.
  13. Added DeepCopy interface implementation.

Database Components

  1. gdb
  2. Added WhereBuilder feature for more flexible SQL condition statement combinations: Model Query - Where
  3. Added HOOK feature for custom hook event handling: ORM Model - Hook
  4. Improved the logic of data conversion processing before submitting to the underlying driver.
  5. Moved the mysql driver from the main library to the community module to facilitate decoupling from the main library. Therefore, from subsequent versions, developers need to manually import driver dependencies: https://github.com/gogf/gf/tree/master/contrib/drivers

Encoding Components

  1. gproperty
  2. Added gproperty component for parsing Java Property format files.
  3. gjson
  4. Added support for encoding, decoding, and manipulating property file format data: General Codec
  5. Fixed the issue of precision loss when reading large integers.

Text Processing

  1. gstr
  2. Improved WordWrap method to be more friendly with Unicode, especially Chinese line breaks.
  3. Fixed the issue where RepliceI ignoring case string replacement in certain scenarios.

Error Handling

  1. gerror
  2. Added Unwrap method (same as Next method) to support the new Golang version Unwrap error interface.
  3. Added Equal method for comparing whether two errors are equal: Error Handling - Comparison
  4. Added Is method to support the new Golang version Is error interface: Error Handling - Comparison

Utility Methods

  1. gconv
  2. Removed support for octal strings when converting integers.
  3. Improved internal implementation logic for readability and maintainability.
  4. gutil
  5. Added gutil.Copy method for deep copying specified content.
  6. Improved gutil.Dump method.

Development Tools

Compared to the stable code components of the main library, CLI development tools have some incompatible updates in recent versions. Please pay attention to release records during upgrades; details are available in the source code adjustments.

  1. Improved build command, supporting specifying the generation directory of pack code files, with some parameter adjustments.
  2. Improved docker command, supporting multiple docker tag renaming and automatic repository pushing.
  3. Improved gen dao command, supporting custom dao/do/entity code generation directory, no longer forced to generate in the service/internal directory: Dao/Do/Entity Generating
  4. Added gen service command, supporting automated generation of service interface code based on logic layer code: Service Generating
  5. Fixed issues with the run command’s custom program startup parameters, gofmt/goimports program path containing spaces.

Incompatibilities

  1. Moved the mysql driver from the main library to the community module to facilitate decoupling from the main library. Therefore, from subsequent versions, developers need to manually import driver dependencies: https://github.com/gogf/gf/tree/master/contrib/drivers
  2. The ghttp.Response.WriteJson/Xml methods no longer return error. Adjust according to the compilation error.
  3. The goai component moved from the protocol category to the net category, changing the import path. Adjust according to the compilation error.
  4. Database ORM operations with gtime.Time type parameters will automatically convert them to time.Time type before submission to the underlying database driver to solve the precision loss issue. This means that gtime.Time type parameters are also affected by the database configuration’s timezone parameters. For details, see: ORM - Timezone