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:

v2.6 2023-12-19 - 图1

Feature Improvements

The minimum required Golang version for the framework has been upgraded from v1.15 to v1.18.

  1. g
    1. Added the g.Go method to conveniently create asynchronous goroutines with ctx and recover parameters.
  2. glog
    1. Improved the Handler callback processing function’s HandlerInput input parameters by adding Values parameter, which is the input parameter list for log printing: Logging - Handler
    2. Added a general method HandlerStructure to print log content with structured parameters: Logging - Handler
    3. Improved the log file rotate logic to solve the problem of failing to rotate files in certain scenarios.
  3. gerror
    1. Added error stack mode (brief/detail): In brief mode, the error stack will only print non-framework component stacks. In detail mode, the error stack will print the complete framework code call chain. The framework uses brief mode by default: Error Handling - Other Features
  4. gcode
    1. Added gcode.CodeInternalPanic error code, and all panic errors captured by framework components will return with this error code.
  5. gmap
    1. Added Diff method for comparing and returning the differences between two Map objects.
  6. gaes
    1. Added PKCS7Padding/PKCS7UnPadding methods.
  7. gdb
    1. Removed ConvertDataForRecord conversion method, added ConvertValueForField conversion method.
    2. Modified the CheckLocalTypeForField method, changing the return parameter type from string to LocalType.
    3. 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.
    4. Added Model.Partition method, allowing users to explicitly specify partition parameters during database operations.
    5. Added Model.LeftJoinOnFields/RightJoinOnFields/InnerJoinOnFields methods, making it easier to implement Join operations.
    6. Fixed the implementation issue of the Model.WherePrefixNotIn method.
  8. gredis
    1. Added Cluster configuration option to specify whether to use cluster mode: Redis - Configuration
    2. Added Protocol configuration option to specify the RESP version: Redis - Configuration
  9. gi18n
    1. Improved translation file reading logic, supporting automatic file reading from resource managers: I18N - Configuration
  10. gclient
    1. Added NoUrlEncode feature, allowing GET requests to not automatically perform UrlEncode on parameters.
  11. ghttp
    1. Improved exit signal handling to support graceful exit upon capture of exit signals on the Windows platform.
  12. goai
    1. Supports automatic recognition of ghttp.UploadFile type as OpenAPIv3 File type.
    2. Removed redundant description information from Path objects and Method objects.
    3. Converts the example field type of the interface into the corresponding data type based on the parameter data type.
  13. gcfg
    1. Added AdapterContent configuration interface implementation, allowing configuration management through specific configuration content: Configuration - AdapterContent
  14. gctx
    1. Added NeverDone method, which wraps a given ctx object and returns a ctx object that never expires or is Cancelled.
  15. gfile
    1. Changed the default file creation mode from 0777 to 0755.
    2. Improved Copy/CopyFile/CopyDir methods, added CopyOption optional parameter to control the copy logic options.
  16. gmutex
    1. Improved gmutex.Mutex object using Golang‘s new version of mutex, directly utilizing the TryLock/TryRLock from the new version standard library. The methods LockFunc/TryLockFunc are retained.
    2. Added gmutex.RWMutex object, extending the standard library’s sync.RWMutex object, with new methods LockFunc/TryLockFunc, RLockFunc/TryRLockFunc.
  17. gstr
    1. Added List2/ListAndTrim2/List3/ListAndTrim3 methods, similar to the PHP list functionality, which splits a string and returns it as multiple result values.
    2. Added CaseConvert method to perform string naming format conversion according to a given CaseType type parameter.
  18. gconv
    1. Added ConvertWithRefer method, which uses the given parameter as a type reference and converts the given parameter to the specified type.
  19. gutil
    1. Added FillStructWithDefault method, which automatically fills the given struct object/pointer with default values by reading the struct tag.
  20. gvalid
    1. Fixed the issue with enums validation rule not supporting map parameter types.

Community Components

Configuration Management

  1. Added contrib/config/consul component, implemented consul service for configuration management component interface: https://github.com/gogf/gf/tree/master/contrib/config/consul

Database Implementation

  1. Improved contrib/drivers/dm component:
  2. Supports schema parameter configuration.
  3. Supports time.Time/*time.Time time type parameter operations.
  4. Improved contrib/drivers/sqlite component to support Insert Ignore and Save operations.
  5. Added contrib/drivers/sqlitecgo component, supporting i386 system architecture through cgo.
  6. Improved contrib/nosql/redis component:
  7. Added TLSConfig configuration to support TLS connection to Redis Server.
  8. Added Protocol configuration option to support the latest version of Redis Server.

Service Registration Discovery

  1. Added contrib/registry/nacos component, implementing microservice registration and discovery using nacos: https://github.com/gogf/gf/tree/master/contrib/registry/nacos
  2. Improved contrib/registry/file component to automatically delete expired registrations, preventing clients from discovering and connecting to expired server addresses.
  3. Fixed some implementation issues in the contrib/registry/polaris component.

Microservice Components

  1. Improved contrib/rpc/grpcx component:
  2. Clients support directly providing connection addresses to access the server.
  3. Enhanced unit tests to improve code quality.

Development Tools

  1. Improved the installation method of the cli tool to additionally support go install installation: go install github.com/gogf/gf/cmd/gf/v2@latest
  2. Improved gf run command by adding WatchPaths/-w configuration, allowing specified path list monitoring to avoid the too many opened files issue caused by monitoring all files in local projects by default: Auto Compiling
  3. Improved gf gen ctrl command by adding Merge/-m option to control the generation of controller code files according to the api layer rather than splitting them into different files based on api interfaces: Controller Generating
  4. Improved gf gen dao command by adding RemoveFieldPrefix/-rf option to automatically remove the prefix of generated table field names: Dao/Do/Entity Generating
  5. Improved gf gen pbentity command by adding RemoveFieldPrefix/-rf option to automatically remove the prefix of generated table field names: DB Table To Protobuf
  6. Improved gf gen service command to automatically generate method comments for objects in the logic module into the service interface file.
  7. Improved gf version/gf -v command for more detailed tool version, runtime environment, and framework information.
  8. Improved the initialization efficiency of development tools, removing init package method logic that affected initialization efficiency.
  9. Fixed the issue of Link database configuration failure in the gf gen dao command.
  10. Other detailed fixes.