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

👋 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 provides 9 types of database driver implementations 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 more driver implementations for domestic databases and contribute to the open-source community.
  • The richness of community components is expanded by adding 3 types of configuration center interface implementations in this release, supporting Apollo/Polaris/Kubernetes ConfigMap. The GoFrame framework 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 44 code contributors in this release, the total number of contributors to the framework has reached 107. We appreciate everyone's efforts and contributions to the community! 💖

Github ChangeLog: https://github.com/gogf/gf/releases/tag/v2.2.0

New Features

  1. Refactored the built-in validation rules manager of the validation component, increasing and supporting 59 commonly used built-in validation rules: Data Validation - Rules
  2. Added the community component contrib/config/kubecm, implementing a configuration component Adapter based on kubernetes configmap: https://github.com/gogf/gf/tree/master/contrib/config/kubecm
  3. Added the community component contrib/config/apollo, implementing a configuration component Adapter based on the apollo configuration center: https://github.com/gogf/gf/tree/master/contrib/config/apollo
  4. Added the community component contrib/config/polaris, implementing a configuration component Adapter based on the polaris configuration center: https://github.com/gogf/gf/tree/master/contrib/config/polaris
  5. Added contrib/drivers/dm support for the domestic Dameng Database: https://github.com/gogf/gf/tree/master/contrib/drivers

Major Improvements

Community Components

ORM Driver Implementation

  1. Improved contrib/drivers/pgsql to support more pgsql built-in data types at the ORM component level.
  2. Improved contrib/drivers/pgsql to support the LastInsertId feature for write operations.
  3. Improved contrib/drivers/clickhouse to support decimal.Decimal data types.
  4. Added contrib/drivers/dm support for the domestic Dameng Database: https://github.com/gogf/gf/tree/master/contrib/drivers

Service Discovery Components

  1. Improved the contrib/registry/etcd implementation by turning the log object into an interface property, allowing external registration of custom log objects.

Configuration Components

  1. Added the community component contrib/config/kubecm, implementing a configuration component Adapter based on kubernetes configmap: https://github.com/gogf/gf/tree/master/contrib/config/kubecm
  2. Added the community component contrib/config/apollo, implementing a configuration component Adapter based on the apollo configuration center: https://github.com/gogf/gf/tree/master/contrib/config/apollo
  3. Added the community component contrib/config/polaris, implementing a configuration component Adapter based on the polaris configuration center: https://github.com/gogf/gf/tree/master/contrib/config/polaris

Database ORM

  1. 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
  2. Improved interface design, simplifying driver implementation logic, making it easier to add more database driver support in the future.
  3. Added the ToSQL method to generate SQL statements for debugging ORM operations without actually executing the SQL.
  4. Added the CatchSQL method to obtain a list of internally executed SQL statements through a closure method.
  5. Deprecated the Core object's GetStruct/GetStructs methods, opting for a unified Scan method for better usability.
  6. Changed the database object's log object to an interface property, allowing for external registration of custom log objects.
  7. Added Extra and Protocol configurations for setting additional configuration parameters and link protocols, with default automatic parsing through Link configuration.
  8. Removed the Filtered interface, adopting a default implementation to simplify complexity and improve usability.
  9. Added ConvertValueForLocal and CheckLocalTypeForField interfaces for custom data type conversion and fetching, with default implementation provided.
  10. Added ClearTableFields method for clearing data structure cache specific to a particular database table: ORM Senior - Field Mapping
  11. Added ClearTableFieldsAll method for clearing all data structure caches for all tables in the current database object: ORM Senior - Field Mapping
  12. Added ClearCache method for clearing all query caches for a particular database table: ORM Model - Query Cache
  13. Added ClearCacheAll method for clearing all query caches for the current database object: ORM Model - Query Cache
  14. Various other improvements.

Encoding and Decoding Component

  1. gcompress
  2. Added GzipPathWriter method for compressing files from a specific path into a specified io.Writer.
  3. Added ZipPathContent method for packaging and compressing files/directories using the zip algorithm and returning byte content.
  4. gjson
  5. Adjusted ContentTypeJson and other string parameters to ContentType type.

Error Handling

  1. Added command-line parameter --gf.gerror.brief and GF_GERROR_BRIEF environment variable switch, controlling whether the framework stack is filtered when printing error stacks: Error Handling - Other Features
  2. Various other detail improvements.

Network Component

  1. ghttp
  2. Added commonly used middleware MiddlewareJsonBody for validating whether the request Body is in JSON format.
  3. Added GetListenedAddress method for getting the listening address when HTTP Server listens on the specified :0 port, where the system randomly assigns a listening address.
  4. Modified the return HTTP status code to 500 when an error occurs on the server side.
  5. gtcp
  6. Added GetListenedAddress/GetListenedPort methods for obtaining the listening address/port when TCP Server listens on the specified :0 port, where the system randomly assigns a listening address/port.
  7. gudp
  8. Added GetListenedAddress/GetListenedPort methods for obtaining the listening address/port when UDP Server listens on the specified :0 port, where the system randomly assigns a listening address/port.
  9. goai
  10. Added support for properties defined in embedded structs when generating API documentation.
  11. Removed duplicate parameter descriptions in the API documentation, especially when identical parameters exist in both URL and Body.
  12. gtrace
  13. Improved the error prompts for the WithTraceID method with more explicit information.
  14. Added WithUUID method for converting standard UUID to OpenTelemetry TraceID.

System Component

  1. gcfg
  2. Adjusted the Available interface method definition, making the resource parameter optional.
  3. gcron
  4. Added time difference calculation logic for scenarios of job delay, minimizing the impact on scheduled jobs whenever possible.
  5. gctx
  6. Added support for cross-process link tracking.
  7. Added GetInitCtx/SetInitCtx method for obtaining and setting the context during the execution of the main package and package init initialization methods.
  8. glog
  9. Added ILogger interface definition for decoupled and interface-based use of log components across components.
  10. Other detail improvements.
  11. gres
  12. Added Export method to the File object, enabling the export of resources associated with this object to a specified disk path.
  13. gstructs
  14. Improved RecursiveOption from int type to a custom type, along with adjustments to the corresponding method parameters.

Text Processing

  1. Added gstr.IsGNUVersion method for determining whether a given string complies with GNU version rules.

Utility Methods

  1. gconv
  2. Improved int64/uint64 conversion support for the special string NaN.
  3. gutil
  4. Added GetOrDefaultStr/GetOrDefaultAny methods for convenient handling of default values and optional parameters.
  5. gvalid
  6. Refactored the built-in validation rules manager, making it very convenient to add a new built-in validation.
  7. Increased and supported 59 commonly used built-in validation rules: Data Validation - Rules

Bug Fixes

  1. Fixed panic issue of DeepCopy in garray/gmap/gset/glist/gtype/gvar when the container object is nil.
  2. Fixed panic issue of DeepCopy in gtime when the object is nil.
  3. Fixed the issue of overwriting multiple sort conditions in the Group method of the ORM chain operation.
  4. Fixed the problem of duplicate output while returning JSON format strings in HTTP Server.
  5. Fixed out-of-bounds array access in the gstr.Nl2Br method caused by logical judgment in some scenarios.
  6. Fixed error print issue when table name is empty while fetching database table field information.
  7. Fixed parameter reception issue of object properties as *gjson.Json type in Req.

Development Tools

  1. Improved gen dao command by adding the clear parameter to automatically clean up local data model Go files that do not exist in the target database: Dao/Do/Entity Generating
  2. Improved gen service command: Service Generating
  3. Integrated interface generation of struct objects by business module.
  4. Added clear parameter to automatically clean up interface code and files not corresponding to logic.
  5. Various other detail improvements.
  6. Improved run command by adding custom program run parameters.