👋 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 provides9
types of databasedriver
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 moredriver
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, supportingApollo/Polaris/Kubernetes ConfigMap
. TheGoFrame
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 reached107
. We appreciate everyone's efforts and contributions to the community! 💖
Github ChangeLog: https://github.com/gogf/gf/releases/tag/v2.2.0
New Features
- Refactored the built-in validation rules manager of the validation component, increasing and supporting
59
commonly used built-in validation rules: Data Validation - Rules - Added the community component
contrib/config/kubecm
, implementing a configuration componentAdapter
based onkubernetes configmap
: https://github.com/gogf/gf/tree/master/contrib/config/kubecm - Added the community component
contrib/config/apollo
, implementing a configuration componentAdapter
based on theapollo
configuration center: https://github.com/gogf/gf/tree/master/contrib/config/apollo - Added the community component
contrib/config/polaris
, implementing a configuration componentAdapter
based on thepolaris
configuration center: https://github.com/gogf/gf/tree/master/contrib/config/polaris - 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
- Improved
contrib/drivers/pgsql
to support morepgsql
built-in data types at the ORM component level. - Improved
contrib/drivers/pgsql
to support theLastInsertId
feature for write operations. - Improved
contrib/drivers/clickhouse
to supportdecimal.Decimal
data types. - Added
contrib/drivers/dm
support for the domestic Dameng Database: https://github.com/gogf/gf/tree/master/contrib/drivers
Service Discovery Components
- Improved the
contrib/registry/etcd
implementation by turning the log object into an interface property, allowing external registration of custom log objects.
Configuration Components
- Added the community component
contrib/config/kubecm
, implementing a configuration componentAdapter
based onkubernetes configmap
: https://github.com/gogf/gf/tree/master/contrib/config/kubecm - Added the community component
contrib/config/apollo
, implementing a configuration componentAdapter
based on theapollo
configuration center: https://github.com/gogf/gf/tree/master/contrib/config/apollo - Added the community component
contrib/config/polaris
, implementing a configuration componentAdapter
based on thepolaris
configuration center: https://github.com/gogf/gf/tree/master/contrib/config/polaris
Database ORM
- 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
- Improved interface design, simplifying
driver
implementation logic, making it easier to add more databasedriver
support in the future. - Added the
ToSQL
method to generate SQL statements for debugging ORM operations without actually executing the SQL. - Added the
CatchSQL
method to obtain a list of internally executed SQL statements through a closure method. - Deprecated the
Core
object'sGetStruct/GetStructs
methods, opting for a unifiedScan
method for better usability. - Changed the database object's log object to an interface property, allowing for external registration of custom log objects.
- Added
Extra
andProtocol
configurations for setting additional configuration parameters and link protocols, with default automatic parsing throughLink
configuration. - Removed the
Filtered
interface, adopting a default implementation to simplify complexity and improve usability. - Added
ConvertValueForLocal
andCheckLocalTypeForField
interfaces for custom data type conversion and fetching, with default implementation provided. - Added
ClearTableFields
method for clearing data structure cache specific to a particular database table: ORM Senior - Field Mapping - Added
ClearTableFieldsAll
method for clearing all data structure caches for all tables in the current database object: ORM Senior - Field Mapping - Added
ClearCache
method for clearing all query caches for a particular database table: ORM Model - Query Cache - Added
ClearCacheAll
method for clearing all query caches for the current database object: ORM Model - Query Cache - Various other improvements.
Encoding and Decoding Component
gcompress
- Added
GzipPathWriter
method for compressing files from a specific path into a specifiedio.Writer
. - Added
ZipPathContent
method for packaging and compressing files/directories using thezip
algorithm and returning byte content. gjson
- Adjusted
ContentTypeJson
and other string parameters toContentType
type.
Error Handling
- Added command-line parameter
--gf.gerror.brief
andGF_GERROR_BRIEF
environment variable switch, controlling whether the framework stack is filtered when printing error stacks: Error Handling - Other Features - Various other detail improvements.
Network Component
ghttp
- Added commonly used middleware
MiddlewareJsonBody
for validating whether the requestBody
is inJSON
format. - Added
GetListenedAddress
method for getting the listening address whenHTTP Server
listens on the specified:0
port, where the system randomly assigns a listening address. - Modified the return HTTP status code to
500
when an error occurs on the server side. gtcp
- Added
GetListenedAddress/GetListenedPort
methods for obtaining the listening address/port whenTCP Server
listens on the specified:0
port, where the system randomly assigns a listening address/port. gudp
- Added
GetListenedAddress/GetListenedPort
methods for obtaining the listening address/port whenUDP Server
listens on the specified:0
port, where the system randomly assigns a listening address/port. goai
- Added support for properties defined in embedded structs when generating API documentation.
- Removed duplicate parameter descriptions in the API documentation, especially when identical parameters exist in both
URL
andBody
. gtrace
- Improved the error prompts for the
WithTraceID
method with more explicit information. - Added
WithUUID
method for converting standardUUID
toOpenTelemetry
TraceID
.
System Component
gcfg
- Adjusted the
Available
interface method definition, making theresource
parameter optional. gcron
- Added time difference calculation logic for scenarios of job delay, minimizing the impact on scheduled jobs whenever possible.
gctx
- Added support for cross-process link tracking.
- Added
GetInitCtx/SetInitCtx
method for obtaining and setting the context during the execution of themain
package and packageinit
initialization methods. glog
- Added
ILogger
interface definition for decoupled and interface-based use of log components across components. - Other detail improvements.
gres
- Added
Export
method to theFile
object, enabling the export of resources associated with this object to a specified disk path. gstructs
- Improved
RecursiveOption
fromint
type to a custom type, along with adjustments to the corresponding method parameters.
Text Processing
- Added
gstr.IsGNUVersion
method for determining whether a given string complies withGNU
version rules.
Utility Methods
gconv
- Improved
int64/uint64
conversion support for the special stringNaN
. gutil
- Added
GetOrDefaultStr/GetOrDefaultAny
methods for convenient handling of default values and optional parameters. gvalid
- Refactored the built-in validation rules manager, making it very convenient to add a new built-in validation.
- Increased and supported
59
commonly used built-in validation rules: Data Validation - Rules
Bug Fixes
- Fixed
panic
issue ofDeepCopy
ingarray/gmap/gset/glist/gtype/gvar
when the container object isnil
. - Fixed
panic
issue ofDeepCopy
ingtime
when the object isnil
. - Fixed the issue of overwriting multiple sort conditions in the
Group
method of the ORM chain operation. - Fixed the problem of duplicate output while returning
JSON
format strings inHTTP Server
. - Fixed out-of-bounds array access in the
gstr.Nl2Br
method caused by logical judgment in some scenarios. - Fixed error print issue when table name is empty while fetching database table field information.
- Fixed parameter reception issue of object properties as
*gjson.Json
type inReq
.
Development Tools
- Improved
gen dao
command by adding theclear
parameter to automatically clean up local data model Go files that do not exist in the target database: Dao/Do/Entity Generating - Improved
gen service
command: Service Generating - Integrated interface generation of struct objects by business module.
- Added
clear
parameter to automatically clean up interface code and files not corresponding tologic
. - Various other detail improvements.
- Improved
run
command by adding custom program run parameters.