Hello, everyone! You’ve been waiting! It’s been just six months since the last release, and many things have happened in this half-year. Schrödinger’s cat determines different outcomes for the kitten by different means of observation, and similarly, the way we view the world shapes how the world appears to us. This time we bring you the latest GoFrame v1.16 version! GoFrame is a modular, high-performance, enterprise-grade Go foundational development framework: https://goframe.org, a low-key, pragmatic enterprise-grade Golang development framework in the true sense! This update includes numerous new features and enhancements, especially full tracing, ORM model association/nested transactions/subqueries/dozens of new methods, HTTP client interceptor, data validation and I18N enhancements, refactored timer, and more. There are a lot of updates this time, below are the major updates, hope you like them! Enjoy!

v1.16 2021-06-01 - 图1

This documentation has been extensively updated, with the total development documentation now containing over 200,000 words. It is recommended to read according to the official directory structure.

Important Features

  1. The framework introduces full tracing, adopting the OpenTelemetry standard, currently integrating HTTP Client&Server/GRPC Client&Server/ORM/Redis/Logging components. For detailed introduction, please refer to the sections:
    1. Tracing - Basic Example
    2. Tracing - HTTP Example
    3. Tracing - GRPC Example
  2. The core database components have added the following features:
    1. Model Association:
      1. Model Association - ScanList
      2. Model Association - With
    2. Nested Transactions: ORM - Transaction
    3. Subquery feature: Model Query - Subquery
    4. Added dozens of ORM model operation methods (referencing PHP Laravel), it is highly recommended for those using goframe to take a look:
      1. ORM - Model 🔥
      2. ORM Model - Insert/Save
      3. ORM Model - Update/Delete
      4. ORM Model - Query
  3. HTTP client adds middleware interceptor functionality, for details, please refer to the section: HTTPClient - Middleware
  4. Extensive improvements to the data validation component:
    1. Added chain operation verification objects: Data Validation - Object
    2. Added support for Context, and enhanced support for powerful I18N international error information management. For details, please refer to the sections:
      1. I18N
      2. Data Validation - Error Msg
    3. Custom validation rules have been improved, with added features for local validation rule registration and full data validation: Data Validation - Custom
  5. The timer component gtimer is fully restructured, removing the TimingWheel implementation and adopting a more robust PriorityQueue improved implementation. For details, refer to the section: Timer
  6. The framework’s core foundational components have added a full error stack feature, allowing complete retrieval of error stack information for related components in the event of an error. This feature is only available in a well-designed, comprehensive foundational component framework.

Functionality Improvements

  1. ORM
    1. Added full tracing context Context parameter passing: ORM - Context During tracing, it will record SQL and database connection information (excluding sensitive configurations), and the component tracing information can be configured to be turned off.
    2. Further improved the ORM component logging, which is only valid in debug mode. For detailed introduction, refer to the section: ORM - Senior Features
    3. Added dozens of ORM model operation methods referencing PHP Laravel, such as InsertAndGetId, Min/Max/Avg/Sum, Increment/Decrement, WhereBetween/WhereLike/WhereIn/WhereNull, OrderAsc/OrderDesc/OrderRandom, etc. It is highly recommended for those using goframe to take a look, for details, refer to the section:
      1. ORM - Model 🔥
      2. ORM Model - Insert/Save
      3. ORM Model - Update/Delete
      4. ORM Model - Query
    4. In the new version, the database ORM chain operation has enabled field filtering by default. Parameters that cannot be intelligently matched with table fields will be automatically filtered. For details, refer to the section: ORM Model - Fields Filtering
    5. Improved the conversion of pgsql database type int8 to Golang type, from int type adjusted to int64.
    6. Extensive refactoring and improvement work have been done, too detailed to describe each. The key result is richer component functionality, more rigorous code, simpler design, and easier use.
  2. HTTP
    1. HTTP Client adds middleware interceptor functionality: HTTPClient - Middleware
    2. HTTP Client&Server adds tracing support: Tracing - HTTP Example
    3. The client request method in the ghttp package is marked deprecated, and will be unified to use the HTTP Client object in the future.
    4. Improved the data validation of Request.Parse method, directly validating submitted parameters instead of the struct object converted from data: Request - Validation
    5. Added WrapF/WrapH methods to convert standard library http.HandlerFunc/http.Handler to service method types supported by ghttp.Server.
    6. Numerous other improvements, with many details. The key outcome is richer component functionality, more rigorous code, and easier use.
  3. gvalid
    1. The Check method name is changed to CheckValue, for details, refer to the section: Data Type - Value
    2. Added CheckStructWithData method to validate the struct object of specified parameters: Struct Validation - Example
    3. Added Validator validation object for convenient chain operation, allowing further expansion later: Data Validation - Object
    4. Custom rule method definitions now include Context variables and added RuleFunc and RuleFuncMap local validation rule registration methods: Data Validation - Custom
    5. Validation methods have added Context parameter support, and improved to support powerful I18N international error information management capabilities:
      1. I18N
      2. Data Validation - Error Msg
    6. Error object is modified to interface implementation, note that previous usage with *Error pointer will result in errors.
    7. Some other detail improvements.
  4. gcache
    1. Added Ctx chain operation method for context parameter input, for details, refer to the section: Caching
    2. The Adapter interface adds Context parameter input, facilitating context parameter passing, and improved adapters in built-in implementation supporting context parameter passing: Caching - Interface
  5. gredis
    1. Added support for tracing, for details, refer to the section: Redis-Context
  6. gjson
    1. The Option type name was changed to Options, this is a breaking change.
    2. The NewWithOption method name was changed to NewWithOptions.
  7. gcmd
    1. Added GetOptWithEnv method and marked GetWithEnv method as deprecated.
  8. glog
    1. Added tracing support based on the OpenTelemetry standard: Logging - Context
  9. gproc
    1. Added unified signal registration listening callback feature: Process - Signal
  10. gres
  11. Best practices for resource management can be found here: Resource - Best Practices
  12. gtimer
  13. Timer component gtimer is fully restructured, removing the TimingWheel implementation, and adopting a more robust PriorityQueue improved implementation. Details can be found here: Timer
  14. gview
  15. All template parsing methods added a Context parameter input: Template Engine
  16. gconv
  17. Improved Scan method by adding automatic conversion support for Map/Maps parameter types: Type Conversion - Scan
  18. gi18n
  19. The I18N internationalization component adds support for Context, for details, refer to the section: I18N
  20. Note that all methods now have a ctx parameter input, and some methods have removed the language parameter, instead controlled by ctx to input language, enhancing extensibility: I18N - Example
  21. Removed TranslateFormatLang and Tfl methods.
  22. gmeta
  23. Newly added gmeta metadata package, for details, refer to the section: Metadata
  24. Other detailed improvements in various components, not necessary to specifically detail in the release documentation.

Development Toolchain

CLI tools have been updated, mainly simplifying dao model code generation, eliminating redundant method generation, and removing methods that directly return model objects. The dao object is modified to directly inherit the GoFrame ORM component’s Model object, accepting query data through the specified model, hence the ways of using some methods may require adjustments.