Hello everyone, the GoFrame framework has officially released version v2.5.0 today! 👏👏👏👏
This version mainly focuses on improvements to existing functional components and development tools, including:
- The development tool introduces a new
gf gen ctrlcommand to standardize the definition and development of API interfaces, and generate code for controllers and SDKs to improve development efficiency, addressing issues of interface standardization and efficiency inGolangproject development. For details, please refer to: Controller Generating. - The existing
gf gen daocommand adds aTypeMappingfeature, allowing developers to customize theGolangtype of entity object properties generated from database tables: Dao/Do/Entity Generating
For other changes, please refer to the following change log. Enjoy! 🍺🍺🍺🍺🍺🍺🍺🍺
Github ChangeLog: https://github.com/gogf/gf/releases/tag/v2.5.0
Full code changes: v2.4.0...v2.5.0, thanks to all the contributing developers for this release:
Feature Improvements
gdb- Improved
ORM SQLlogging, with operations executed according to the order defined in the table fields. - Improved
HOOKmethod implementation, now supports modifying theTablefield in theinparameter to change the executed table name. - Added
AllAndCount/ScanAndCountmethods for convenient pagination query scenarios. - Added
Model.WhereOrNot/WhereOrPrefixNotcondition methods.
- Improved
gi18n- Improved support for Chinese (
Unicode) as key names for translation.
- Improved support for Chinese (
gclient- Added
Discoverychain operation method for setting service discovery components for the current request.
- Added
ghttp- Improved request
Contextprocessing, where each change inContextwill affect the underlyinghttp.Requestobject. This supports customHTTP Handlerdata interaction scenarios. - Added support for
Endpointsconfiguration item to customize the service registration discovery address of theServer, allowing the use of the currently listening address.
- Improved request
goai- Improved parameter validation recognition, marking required parameters in the
OpenAPIv3results.
- Improved parameter validation recognition, marking required parameters in the
gsel- Fixed locking mechanism issues for
Endpointsupdates in theRoundRobinimplementation.
- Fixed locking mechanism issues for
glog- Added
TimeFormatconfiguration for customizing the time format of log output: Logging - Configuration - Improved
Rotationimplementation to support log file splitting for short-running programs.
- Added
gtag- Added
GetGlobalEnumsmethod to obtain globally registered enum types.
- Added
gutil- Added
DumpJsonmethod to format and print any type of variable to the terminal inJSON, making it easier for human reading.
- Added
gvalid- Added
enumsvalidation rule for automatic recognition and validation of enum types: Data Validation - Rules
- Added
Community Components
- Fixed load balancing issue of
contrib/registry/polariscomponent when there are multiple servers. - Improved
contrib/drivers/pgsqlto have theIndexfield inTableFieldsreturn start uniformly from0. - Improved
contrib/nosql/rediswith added user configuration support. - Improved
contrib/rpc/grpcxcomponent, with the addition ofEndpointsconfiguration support forgrpcx.Server, enabling customizable service registration discovery addresses. - Added
contrib/sdk/httpclientcomponent, dependent library forHTTP SDKcode files generated by the newly addedgf gen ctrlcommand in this version. - Added
contrib/trace/otlpgrpcandcontrib/trace/otlphttpcomponents for unified connection of tracing based onOpenTelemetry.
Development Tools
- Added
gf gen ctrlcommand for compilingapidefinition directories, automatically generating standardizedcontroller,HTTP SDKcode: Controller Generating - Improved
gf gen daocommand, addedTypeMappingfeature, allowing developers to customize the mapping of data table field types and generatedGoentity data structure property types, and conveniently introduce third-party package types (such asdecimalpackage for high-precision types): Dao/Do/Entity Generating - Improved
gf gen enumscommand, changedPrefixparameter toPrefixesto support specifying prefixes for multiple generated enum type packages: Enums Maintenance - Improved
gf gen servicecommand:- Added method comment generation in the generated
servicefile. - When there is an
importconflict in the generatedservicefile, automatically generateimport alias.
- Added method comment generation in the generated
- Improved command-line packaging, exposing
gfcmd.Commandtype for developers to extend custom command-line functions. - Improved
gf dockercommand, setting build file parameters as non-mandatory (for compatibility), which will be used only forDockerbuilds in the future without coupling binary build functions. For full build requirements, it is recommended to use it withgf build. Updatedmake imagecommand in the project template, usinggf build+gf dockercommands. - Improved
gf initcommand, fixed issues in some scenarios where initializing projects covered existing.git/.gitignoredirectories and files or permission errors. - Improved
gf upcommand, fixed issues with framework version updates in certain scenarios, and installation problems under thewindowssystem. - Improved
gf versioncommand, fixed issues with framework version recognition in some scenarios. - Fixed
gf gen pbentitycommand, modifying thefloat32/float64/[]bytetypes in the generatedprotofile entity data structure tofloat/double/bytestypes. - Improved development tools, some commands do not need to explicitly configure
importPrefixparameter, such as:gf gen dao/service
Compatibility Notice
- In
ghttp.Request, theContextand thecontext.Contextreturned byGetCtxmethod have removed the nesting ofNeverDoneCtx, meaning thectxcontext object passed by default in the controller fully inherits from thectxin the standard library'shttp.Request. TheDonemethod will be automatically called to terminate it at the end of a request, and thisctxcannot be propagated to async processes that need further execution. Therefore, starting with this version, users might encounter the following two issues:- To propagate to async processes or maintain compatibility with previous logic: Add a middleware that calls
r.SetCtx(r.GetNeverDoneCtx())to globally override the subsequentctxusage with a never-endingctx.
- To propagate to async processes or maintain compatibility with previous logic: Add a middleware that calls

- When the client actively cancels the request, the server might encounter a
context cancelederror. This is normal, and when the client no longer needs the request result, it will cancel the request, continuing to execute on the server-side makes no sense. If you mind this error, you can refer to the middleware above to addNeverDoneCtx, and the server will ignore the client's cancel and continue to execute.
