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!
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
- The framework introduces full tracing, adopting the
OpenTelemetry
standard, currently integratingHTTP Client&Server/GRPC Client&Server/ORM/Redis/Logging
components. For detailed introduction, please refer to the sections: - The core database components have added the following features:
- Model Association:
- Nested Transactions: ORM - Transaction
- Subquery feature: Model Query - Subquery
- Added dozens of ORM model operation methods (referencing
PHP Laravel
), it is highly recommended for those usinggoframe
to take a look:
- HTTP client adds middleware interceptor functionality, for details, please refer to the section: HTTPClient - Middleware
- Extensive improvements to the data validation component:
- Added chain operation verification objects: Data Validation - Object
- Added support for
Context
, and enhanced support for powerfulI18N
international error information management. For details, please refer to the sections: - Custom validation rules have been improved, with added features for local validation rule registration and full data validation: Data Validation - Custom
- The timer component
gtimer
is fully restructured, removing theTimingWheel
implementation and adopting a more robustPriorityQueue
improved implementation. For details, refer to the section: Timer - 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
ORM
- Added full tracing context
Context
parameter passing: ORM - Context During tracing, it will recordSQL
and database connection information (excluding sensitive configurations), and the component tracing information can be configured to be turned off. - Further improved the
ORM
component logging, which is only valid in debug mode. For detailed introduction, refer to the section: ORM - Senior Features - Added dozens of
ORM
model operation methods referencingPHP Laravel
, such asInsertAndGetId
,Min/Max/Avg/Sum
,Increment/Decrement
,WhereBetween/WhereLike/WhereIn/WhereNull
,OrderAsc/OrderDesc/OrderRandom
, etc. It is highly recommended for those usinggoframe
to take a look, for details, refer to the section: - 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 - Improved the conversion of
pgsql
database typeint8
toGolang
type, fromint
type adjusted toint64
. - 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.
- Added full tracing context
HTTP
HTTP Client
adds middleware interceptor functionality: HTTPClient - MiddlewareHTTP Client&Server
adds tracing support: Tracing - HTTP Example- The client request method in the
ghttp
package is marked deprecated, and will be unified to use theHTTP Client
object in the future. - Improved the data validation of
Request.Parse
method, directly validating submitted parameters instead of thestruct
object converted from data: Request - Validation - Added
WrapF/WrapH
methods to convert standard libraryhttp.HandlerFunc/http.Handler
to service method types supported byghttp.Server
. - Numerous other improvements, with many details. The key outcome is richer component functionality, more rigorous code, and easier use.
gvalid
- The
Check
method name is changed toCheckValue
, for details, refer to the section: Data Type - Value - Added
CheckStructWithData
method to validate thestruct
object of specified parameters: Struct Validation - Example - Added
Validator
validation object for convenient chain operation, allowing further expansion later: Data Validation - Object - Custom rule method definitions now include
Context
variables and addedRuleFunc
andRuleFuncMap
local validation rule registration methods: Data Validation - Custom - Validation methods have added
Context
parameter support, and improved to support powerfulI18N
international error information management capabilities: Error
object is modified to interface implementation, note that previous usage with*Error
pointer will result in errors.- Some other detail improvements.
- The
gcache
- Added
Ctx
chain operation method for context parameter input, for details, refer to the section: Caching - The
Adapter
interface addsContext
parameter input, facilitating context parameter passing, and improved adapters in built-in implementation supporting context parameter passing: Caching - Interface
- Added
gredis
- Added support for tracing, for details, refer to the section: Redis-Context
gjson
- The
Option
type name was changed toOptions
, this is a breaking change. - The
NewWithOption
method name was changed toNewWithOptions
.
- The
gcmd
- Added
GetOptWithEnv
method and markedGetWithEnv
method as deprecated.
- Added
glog
- Added tracing support based on the
OpenTelemetry
standard: Logging - Context
- Added tracing support based on the
gproc
- Added unified signal registration listening callback feature: Process - Signal
gres
- Best practices for resource management can be found here: Resource - Best Practices
gtimer
- Timer component
gtimer
is fully restructured, removing theTimingWheel
implementation, and adopting a more robustPriorityQueue
improved implementation. Details can be found here: Timer gview
- All template parsing methods added a
Context
parameter input: Template Engine gconv
- Improved
Scan
method by adding automatic conversion support forMap/Maps
parameter types: Type Conversion - Scan gi18n
- The
I18N
internationalization component adds support forContext
, for details, refer to the section: I18N - Note that all methods now have a
ctx
parameter input, and some methods have removed thelanguage
parameter, instead controlled byctx
to inputlanguage
, enhancing extensibility: I18N - Example - Removed
TranslateFormatLang
andTfl
methods. gmeta
- Newly added
gmeta
metadata package, for details, refer to the section: Metadata - 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.