Hello everyone, the GoFrame
framework has officially released version v2.6.0
today!👏👏👏👏
This release mainly involves a lot of code improvements and BugFix
work. Due to the numerous changes in this version, the following is a Chinese introduction to some of the more important improvements. For a detailed ChangeLog
, please refer to (especially for BugFix
): https://github.com/gogf/gf/releases/tag/v2.6.0
Complete code changes: https://github.com/gogf/gf/compare/v2.5.0…v2.6.0
Thanks to all the contributing developers in this release:
Feature Improvements
The minimum required Golang version for the framework has been upgraded from v1.15
to v1.18
.
g
- Added the
g.Go
method to conveniently create asynchronousgoroutines
withctx
andrecover
parameters.
- Added the
glog
- Improved the
Handler
callback processing function’sHandlerInput
input parameters by addingValues
parameter, which is the input parameter list for log printing: Logging - Handler - Added a general method
HandlerStructure
to print log content with structured parameters: Logging - Handler - Improved the log file
rotate
logic to solve the problem of failing torotate
files in certain scenarios.
- Improved the
gerror
- Added error stack mode (
brief/detail
): Inbrief
mode, the error stack will only print non-framework component stacks. Indetail
mode, the error stack will print the complete framework code call chain. The framework usesbrief
mode by default: Error Handling - Other Features
- Added error stack mode (
gcode
- Added
gcode.CodeInternalPanic
error code, and allpanic
errors captured by framework components will return with this error code.
- Added
gmap
- Added
Diff
method for comparing and returning the differences between twoMap
objects.
- Added
gaes
- Added
PKCS7Padding/PKCS7UnPadding
methods.
- Added
gdb
- Removed
ConvertDataForRecord
conversion method, addedConvertValueForField
conversion method. - Modified the
CheckLocalTypeForField
method, changing the return parameter type fromstring
toLocalType
. - These are mainly used for database implementations and usually in community components. If a user has local implementations for the
gdb.DB
interface, they should be aware of this change. - Added
Model.Partition
method, allowing users to explicitly specify partition parameters during database operations. - Added
Model.LeftJoinOnFields/RightJoinOnFields/InnerJoinOnFields
methods, making it easier to implementJoin
operations. - Fixed the implementation issue of the
Model.WherePrefixNotIn
method.
- Removed
gredis
- Added
Cluster
configuration option to specify whether to use cluster mode: Redis - Configuration - Added
Protocol
configuration option to specify theRESP
version: Redis - Configuration
- Added
gi18n
- Improved translation file reading logic, supporting automatic file reading from resource managers: I18N - Configuration
gclient
- Added
NoUrlEncode
feature, allowingGET
requests to not automatically performUrlEncode
on parameters.
- Added
ghttp
- Improved exit signal handling to support graceful exit upon capture of exit signals on the Windows platform.
goai
- Supports automatic recognition of
ghttp.UploadFile
type asOpenAPIv3
File
type. - Removed redundant description information from
Path
objects andMethod
objects. - Converts the example field type of the interface into the corresponding data type based on the parameter data type.
- Supports automatic recognition of
gcfg
- Added
AdapterContent
configuration interface implementation, allowing configuration management through specific configuration content: Configuration - AdapterContent
- Added
gctx
- Added
NeverDone
method, which wraps a givenctx
object and returns actx
object that never expires or isCancelled
.
- Added
gfile
- Changed the default file creation mode from
0777
to0755
. - Improved
Copy/CopyFile/CopyDir
methods, addedCopyOption
optional parameter to control the copy logic options.
- Changed the default file creation mode from
gmutex
- Improved
gmutex.Mutex
object usingGolang
‘s new version ofmutex
, directly utilizing theTryLock/TryRLock
from the new version standard library. The methodsLockFunc/TryLockFunc
are retained. - Added
gmutex.RWMutex
object, extending the standard library’ssync.RWMutex
object, with new methodsLockFunc/TryLockFunc, RLockFunc/TryRLockFunc
.
- Improved
gstr
- Added
List2/ListAndTrim2/List3/ListAndTrim3
methods, similar to thePHP list
functionality, which splits a string and returns it as multiple result values. - Added
CaseConvert
method to perform string naming format conversion according to a givenCaseType
type parameter.
- Added
gconv
- Added
ConvertWithRefer
method, which uses the given parameter as a type reference and converts the given parameter to the specified type.
- Added
gutil
- Added
FillStructWithDefault
method, which automatically fills the given struct object/pointer with default values by reading thestruct tag
.
- Added
gvalid
- Fixed the issue with
enums
validation rule not supportingmap
parameter types.
- Fixed the issue with
Community Components
Configuration Management
- Added
contrib/config/consul
component, implementedconsul
service for configuration management component interface: https://github.com/gogf/gf/tree/master/contrib/config/consul
Database Implementation
- Improved
contrib/drivers/dm
component: - Supports
schema
parameter configuration. - Supports
time.Time/*time.Time
time type parameter operations. - Improved
contrib/drivers/sqlite
component to supportInsert Ignore
andSave
operations. - Added
contrib/drivers/sqlitecgo
component, supportingi386
system architecture throughcgo
. - Improved
contrib/nosql/redis
component: - Added
TLSConfig
configuration to supportTLS
connection toRedis Server
. - Added
Protocol
configuration option to support the latest version ofRedis Server
.
Service Registration Discovery
- Added
contrib/registry/nacos
component, implementing microservice registration and discovery usingnacos
: https://github.com/gogf/gf/tree/master/contrib/registry/nacos - Improved
contrib/registry/file
component to automatically delete expired registrations, preventing clients from discovering and connecting to expired server addresses. - Fixed some implementation issues in the
contrib/registry/polaris
component.
Microservice Components
- Improved
contrib/rpc/grpcx
component: - Clients support directly providing connection addresses to access the server.
- Enhanced unit tests to improve code quality.
Development Tools
- Improved the installation method of the
cli
tool to additionally supportgo install
installation:go install github.com/gogf/gf/cmd/gf/v2@latest
- Improved
gf run
command by addingWatchPaths/-w
configuration, allowing specified path list monitoring to avoid thetoo many opened files
issue caused by monitoring all files in local projects by default: Auto Compiling - Improved
gf gen ctrl
command by addingMerge/-m
option to control the generation of controller code files according to theapi
layer rather than splitting them into different files based onapi
interfaces: Controller Generating - Improved
gf gen dao
command by addingRemoveFieldPrefix/-rf
option to automatically remove the prefix of generated table field names: Dao/Do/Entity Generating - Improved
gf gen pbentity
command by addingRemoveFieldPrefix/-rf
option to automatically remove the prefix of generated table field names: DB Table To Protobuf - Improved
gf gen service
command to automatically generate method comments for objects in thelogic
module into theservice
interface file. - Improved
gf version/gf -v
command for more detailed tool version, runtime environment, and framework information. - Improved the initialization efficiency of development tools, removing
init
package method logic that affected initialization efficiency. - Fixed the issue of
Link
database configuration failure in thegf gen dao
command. - Other detailed fixes.