Skip to main content
Version: 2.8.x(Latest)

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 💖💖💖

GoFrame v2.9 Contributors

Compatibility Notes

  1. net/client

    • When the global service registration and discovery component is enabled, the HTTP Client objects created by this component no longer enable service discovery by default. Manual activation is required.
  2. os/glog

    • The default time printing format for logs has been adjusted to the more rigorous 2006-01-02T15:04:05.000Z07:00.

Component Improvements

  1. 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/WhereNotExists method support, enhancing subquery capabilities: ORM Query - Where Conditions
    • Added support for unix socket database connection configuration, providing more connection options.
    • Fixed an issue where using gdb.Counter type in the OnDuplicate method was ineffective: ORM Chain Operation - Write and Save
    • Fixed an issue where when users add a Select Hook and modify the return structure, it causes abnormal query results in Count/Value/Array in some scenarios.
    • Fixed an issue where the orm tag in the metadata tag of embedded struct in the data structure becomes ineffective when using the with feature.
    • Fixed an incompatibility issue with older versions where tinyint(1)/int(1) types are identified as bool type.
    • Fixed an incompatibility issue with older versions in the Order("id", "desc") statement in the database/gdb component.
    • Optimized ORM query performance and memory usage efficiency.
  2. net/ghttp

    • Added common middleware MiddlewareGzip support for compressing return results using the gzip algorithm, improving transmission efficiency and performance.
    • Added HandlerItemParsed.GetMetaTag method, which can be used to get the interface definition metadata information through the GetMetaTag method after getting the current route execution method through GetServeHandler, enhancing route metadata management capabilities.
    • Removed the *Req/*Res naming rule restriction for input and output data structures when defining api in 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 Origin from Referer in cross-domain return Header is not rigorous, enhancing CORS security.
    • Fixed an issue where the json omitempty tag is ineffective when the BuildParams method builds request parameters.
    • Fixed a null pointer panic issue that would occur when Logger is set to nil, improving component stability.
  3. util/gconv

    • Added Converter conversion 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 Scan method, adding support for Scan to basic data type conversion: Type Conversion - Scan Conversion
    • Optimized type conversion performance, improving large data volume conversion efficiency.
  4. net/goai

    • Support for the latest OpenAPIv3.1 protocol 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/between as corresponding validation data structures in OpenAPIv3, simplifying document generation: API Documentation - OpenAPIv3
    • Fixed an issue where the embedded struct data structure in parameter data structures cannot be expanded into parameter structures, improving complex data structure support.
    • Optimized document generation performance and memory usage.
  5. net/client

    • When the global service registration and discovery component is enabled, the HTTP Client objects created by this component no longer enable service discovery by default and need to be manually enabled: Service Registration and Discovery
  6. os/gcache

    • Fixed an issue where the data type returned by the Remove method in the component is incompatible with older versions.
  7. errors/gerror

  8. utils/gvalid

    • Fixed an issue where enums validation becomes ineffective when using pointers with enums parameters.
    • Fixed an issue of excessive memory usage caused by large binary content []byte in parameter validation.
  9. os/glog

    • The default time printing format for logs has been adjusted to the more rigorous 2006-01-02T15:04:05.000Z07:00.
  10. os/gsession

    • Added RegenerateId/MustRegenerateId method support for manually regenerating Session ID to prevent session fixation attacks: Session - RegenerateId
  11. os/gview

    • Fixed an issue where template files could not be read from the resource manager in some scenarios.
  12. os/gcmd

    • Command line parameter default values now support output to the command help interface.
  13. net/gipv4

    • Improved the implementation logic for converting between ip addresses and uint32.
  14. test/gtest

Community Components

  1. contrib/drivers/pgsql

    • Added conversion support for pgsql array field types varchar[]/text[], automatically converting to Go []string type.
    • Improved array type conversion performance.
  2. contrib/config/polaris

    • Added support for more data format contents, supporting formats such as yaml/toml/json/xml/ini/properties.
  3. contrib/registry/consul

  4. contrib/registry/etcd

    • Added retry mechanism, solving the renewal problem when the lease lease expires.
    • Removed the default AutoSyncInterval configuration item, solving the etcd blocking problem caused by this default configuration in some scenarios.
  5. contrib/registry/zookeeper

    • Fixed an error in the component where service name paths with additional suffix - were incorrectly monitored.
  6. contrib/config/nacos

    • Added OnChange callback configuration support.
  7. contrib/metric/otelmetric

    • Added WithExemplarFilter option support.

Development Tools

  1. Improved the gf init command, changing the template content for initializing projects, with no change in directory structure.
  2. Improved the gf up command, displaying a more elegant cli file download interface effect in the terminal, enhancing user experience.
  3. Improved the gf gen ctrl command, automatically synchronizing comments defined in api to the generated controller code, reducing duplicate work.
  4. Improved the gf gen dao command:
    • Added sharding option parameter shardingPattern/sp for defining table sharding rules, generating dao code that supports database sharding, working with ORM database sharding features: Data Specification - gen dao
    • Improved code generation templates, supporting Golang Template syntax, providing more flexible code generation capabilities.
    • Optimized the quality and readability of generated code.
  5. Improved the gf gen enums command:
    • 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.
  6. Improved the gf gen genpbentity command:
    • Added TypeMapping and FieldMapping feature support, providing more flexible type mapping: Database Table PB - gen pbentity
    • Added TablesEx support, allowing specific tables to be ignored when generating proto files, increasing flexibility.
    • Added the GoPackage option for specifying the go_package configuration item in generated proto files, better supporting modularization.
  7. Fixed an issue with the gf build command where environment variables were not accurately printed; it should print the actual environment variables used when compiling files after modifying environment variables.
  8. Fixed an issue with the gf gen pb command where custom tags were repeatedly added after multiple executions of the command with the -a option in some scenarios.
  9. Fixed an issue in the cmd/gf component where commands in the Makefile file generated in the project template by the make command were incorrect.
  10. Overall improvement in command line tool usability and stability.
Ask me