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
- The development tool introduces the
gen service
command, supporting automated generation ofservice
interface code and implementation injection based on thelogic
layer code: Service Generating - Database Features:
- Added
WhereBuilder
feature for more flexibleSQL
condition statement combinations: Model Query - Where - Added
Hook
feature for custom hook event handling: ORM Model - Hook - The framework adds a
DeepCopy
feature for deep copying of types: - Added
gutil.Copy
method for deep copying specified content. - Generic types add a
Copy
method for deep copying their own content. - 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
- Added
drivers/clickhouse
for hookingclickhouse
to thegoframe ORM
component. - Complete unit tests for
clickhouse/mssql/pgsql/sqlite/oracle
components. - 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
- Added
polaris
North Star service registration interface implementation: https://github.com/gogf/gf/tree/master/contrib/registry/polaris - Improved the
etcd
service registration discovery interface implementation component: https://github.com/gogf/gf/tree/master/contrib/registry/etcd
Registration Discovery
- Improved the
Service
implementation object to an interface definition and provided a defaultService
implementation for improved extensibility and usability. - Improved
HTTP/GRPC Client&Server
interface implementations.
Load Balancing
- Improved the
Node
interface definition and added theNodes
interface definition. - Fixed the load balancing issue under the
HTTP Client
.
Network Components
gclient
- Improved service discovery implementation logic.
- Fixed client shutdown error causing connection pool reuse issues.
ghttp
- Improved
Request.GetUrl
method details forURL Schema
. - Parameter reception supports automatic receipt of
UploadFile
attributes. - Added custom UI guidance documentation for interface documentation: API Document - Custom UI
- Changed the default external
JS CDN
dependency for interface documentation tounpkg.com
. - Improved service registration implementation logic.
- Improved internal detail implementation logic.
- Fixed the parameter empty judgment issue.
goai
- Improved adherence to the
OpenAPIV3
protocol implementation. - Supports all custom tags starting with
x-
, automatically adding them to theOpenAPIV3
results. - The component moved from the
protocol
category to thenet
category, changing theimport
path.
System Components
gcfg
- The default file system interface implements support for the
property
file format. gcmd
- Parameter parsing adds
CaseSensitive
configuration, default parsing is case-insensitive, especially affecting structured parameter reception: Command - Structure - Added cross-process link tracking feature: Command - Tracing
glog
- Added a global
Handler
setting function, allowing developers to globally customize handling of all logs of theglog
component, such as globally outputting in theJSON
file format: Logging - Handler - Added the default
JSON
formatHandler
for developers to use: Logging - Handler gsession
- Resolved excessive memory usage issues caused by too many user accesses.
gproc
- Added cross-process link tracking feature: Process - Tracing
Container Components
garray
- Improved the
Unique
method performance, addedDeepCopy
interface implementation. glist
- Added
DeepCopy
interface implementation. gmap
- Added
DeepCopy
interface implementation. gset
- Added
DeepCopy
interface implementation. gtype
- Added
DeepCopy
interface implementation. gvar
- Added
Copy
method for deep copying the current generic object. - Added
DeepCopy
interface implementation.
Database Components
gdb
- Added
WhereBuilder
feature for more flexibleSQL
condition statement combinations: Model Query - Where - Added
HOOK
feature for custom hook event handling: ORM Model - Hook - Improved the logic of data conversion processing before submitting to the underlying
driver
. - 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
gproperty
- Added
gproperty
component for parsingJava Property
format files. gjson
- Added support for encoding, decoding, and manipulating
property
file format data: General Codec - Fixed the issue of precision loss when reading large integers.
Text Processing
gstr
- Improved
WordWrap
method to be more friendly withUnicode
, especially Chinese line breaks. - Fixed the issue where
RepliceI
ignoring case string replacement in certain scenarios.
Error Handling
gerror
- Added
Unwrap
method (same asNext
method) to support the newGolang
versionUnwrap
error interface. - Added
Equal
method for comparing whether two errors are equal: Error Handling - Comparison - Added
Is
method to support the newGolang
versionIs
error interface: Error Handling - Comparison
Utility Methods
gconv
- Removed support for octal strings when converting integers.
- Improved internal implementation logic for readability and maintainability.
gutil
- Added
gutil.Copy
method for deep copying specified content. - 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.
- Improved
build
command, supporting specifying the generation directory ofpack
code files, with some parameter adjustments. - Improved
docker
command, supporting multipledocker tag
renaming and automatic repository pushing. - Improved
gen dao
command, supporting customdao/do/entity
code generation directory, no longer forced to generate in theservice/internal
directory: Dao/Do/Entity Generating - Added
gen service
command, supporting automated generation ofservice
interface code based onlogic
layer code: Service Generating - Fixed issues with the
run
command’s custom program startup parameters,gofmt/goimports
program path containing spaces.
Incompatibilities
- 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 - The
ghttp.Response.WriteJson/Xml
methods no longer returnerror
. Adjust according to the compilation error. - The
goai
component moved from theprotocol
category to thenet
category, changing theimport
path. Adjust according to the compilation error. - Database
ORM
operations withgtime.Time
type parameters will automatically convert them totime.Time
type before submission to the underlying databasedriver
to solve the precision loss issue. This means thatgtime.Time
type parameters are also affected by the database configuration’s timezone parameters. For details, see: ORM - Timezone