Skip to main content
Version: 2.10.x(Latest)

Main Content

GoFrame v2.10 brings a significant number of important features and optimizations, with the most notable being comprehensive generic support for container components, greatly enhancing type safety and development experience. This release also introduces automatic configuration binding and watching mechanisms, RSA encryption and SHA256 hash support, database connection pool optimization, type conversion enhancements, and more. Additionally, development tools have been improved in multiple areas, including more flexible table name wildcard matching and more comprehensive unit test coverage. These new features and improvements will significantly enhance the framework's usability, performance, and development efficiency.

The following are the main contents of this version. For detailed Change Log, please refer to: https://github.com/gogf/gf/releases/tag/v2.10.0

For complete code changes, please refer to: https://github.com/gogf/gf/compare/v2.9.0...v2.10.0

Special Thanks

💖💖💖 Thanks to all developers who contributed to this version 💖💖💖

Compatibility Notes

  1. All container components now fully support generics. In addition to new generic types, existing container types have been migrated to type-safe generic implementations.

  2. The util/gpage pagination component has been marked as deprecated. It is recommended to use the ORM pagination feature or implement pagination logic yourself.

Component Improvements

  1. container/garray

    • Added generic arrays SortedTArray and TArray, providing type-safe array operations with support for custom comparison functions.
    • Enhanced generic array implementation, optimizing performance and memory usage. #4482, #4470, #4466
  2. container/gmap

    • Added generic HashMap[K, V], ListMap[K, V], and TreeMap[K, V], providing type-safe map operations.
    • Added NewXXXWithChecker series functions, supporting custom nil value checkers to solve typed Nil issues. #4520, #4484, #4610, #4605
  3. container/gset

    • Added generic Set[T], providing type-safe set operations.
    • Added NewXXXWithChecker series functions, supporting custom nil value checkers. #4492, #4605
  4. container/glist

    • Added generic List[T], providing type-safe doubly linked list operations.
    • Improved unit tests and example code. #4483
  5. container/gqueue

    • Added generic Queue[T], providing type-safe queue operations.
    • Optimized queue length calculation and loop structures in test cases. #4497, #4455
  6. container/gring

    • Added generic Ring[T], providing type-safe ring buffer operations. #4496
  7. container/gpool

    • Added generic Pool[T], providing type-safe object pool operations. #4493
  8. container/gtree

    • Added generic Tree[K, V], providing type-safe tree structure operations.
    • Added NewXXXWithChecker series functions, supporting custom nil value checkers. #4522, #4610
  9. container

    • Refactored container components, added default nil checker, migrated instance containers to type-safe generics. #4630, #4617
  10. database/gdb

    • Added MaxIdleConnTime configuration option to support setting the maximum lifetime of idle connections in the connection pool, optimizing connection pool management. #4625
    • Added lock update skip locked support, providing more flexible row locking mechanisms. #4607
    • Added table field metadata setting feature; when generating dao, table field registration code can be automatically generated for convenient field management and validation. #4460
    • Added ability to retrieve all configurations, facilitating validation and other business operations. #4389
    • Optimized SoftTime soft delete time feature, improving usability. #4559
    • Optimized performance when grouping fields, improving query efficiency. #4440
    • Fixed issue where raw SQL Count ignores Where conditions. #4611
    • Fixed panic handling in DoCommit to prevent blocking when database driver panics. #4423
    • Fixed cache error overwrite issue caused by using fixed cache keys in pagination queries. #4339
    • Fixed iTableName interface detection issue when executing Scan on reflect.Value objects using WithAll. #4606
    • Fixed field filtering issue in FieldsPrefix when table name/alias is unknown. #4602
    • Fixed column name ambiguity in GROUP BY/ORDER BY for MySQL JOIN. #4521
    • Fixed incorrect schema in database output logs when using database sharding feature. #4319
    • Fixed GetArray return type and added Bools method. #4452
    • Simplified order and group by alias reference logic, improving code readability. #4555
    • Added quotes to FieldsPrefix to ensure field name correctness. #4485
    • Supported multiple order fields in with.
  11. net/ghttp

    • Enhanced GetHeader method to support setting default values, simplifying code logic. #4210
    • Improved GetMetaTag method to handle nil and type checking, enhancing robustness.
    • Fixed form field value truncation issue when uploading files. #4627
    • Fixed route custom parameter recognition anomaly. #4549
    • Fixed issue where @ is added in binding handler pattern when Server Domain is an empty string. #4100, #4101
    • Fixed query parameter in-tag parameter parsing error. #4227, #4228
    • Fixed attachment filename support for utf8 encoding. #4459
    • Fixed related issues. #4567, #4569
  12. util/gconv

    • Added OmitEmpty and OmitNil options for Scan function, providing more flexible type conversion control. #4584
    • Fixed incompatibility issue when converting from old implementation to nil pointer targets, ensuring backward compatibility. #4224
    • Fixed data loss issue when converting nested map in MapToMap. #4612
    • Fixed unsafe string to bytes conversion. #4600
    • Fixed scanning functionality for deep slice types.
  13. os/gcfg

    • Added Loader feature, supporting automatic struct binding and configuration watching, similar to Spring Boot's @ConfigurationProperties annotation, greatly simplifying configuration management. #4575
    • Added file watcher support with custom callbacks, providing more flexible configuration change handling. #4446
    • Restored default behavior where configuration files take precedence over environment variables and command-line parameters, maintaining consistency with older versions. #4647
    • Fixed ignoring fsnotify event errors to avoid complete failure of gcfg package. #4400
  14. os/gfile

    • Added MatchGlob function, supporting globstar pattern matching, providing more powerful file path matching capabilities. #4570, #4574
  15. os/gtime

    • Fixed gtime time string processing logic, improving parsing accuracy. #4409
    • Added handling for nil time pointers to avoid panic. #4323
  16. os/gcache

    • Optimized default cache lazy initialization, reducing unnecessary resource occupation. #4468
  17. os/gcron

    • Fixed occasional unit test failures in gcron package, improving test stability. #4419
  18. encoding/gjson

    • Enhanced automatic type checking when loading data without specified types, improving JSON processing intelligence. #4637
    • Fixed gjson data race issue, ensuring concurrent safety. #4510
  19. net/gclient

    • Optimized default http.Transport connection pool configuration, improving network request performance. #4390
    • Fixed form field value truncation issue when uploading files. #4627
    • Fixed content-type 'application/json;charset=utf-8' issue. #4369
  20. net/goai

    • Added openapi uuid.UUID type support, completing the type system. #4604
    • Fixed swagger $ref replacement issue. #4512
    • Fixed issue with passing g.Meta as request parameter. #4397
  21. util/gvalid

    • Added more validation rules: alpha, alpha-dash, alpha-num, lowercase, numeric, uppercase, enhancing data validation capabilities. #4601
    • Fixed issue where +.1 passes numeric check, ensuring validation accuracy. #4374
  22. util/gutil

    • Fixed false positive circular detection in Dump, improving debugging experience. #2902, #4626
    • Fixed usage of deprecated variable {format} in util/gval. #4258
  23. crypto/grsa

    • Added RSA encryption and decryption functionality, providing complete RSA encryption support, including public key encryption, private key decryption, and other operations. #4571
  24. crypto/gsha256

    • Added gsha256 component, providing SHA256 hash calculation functionality. #4558
  25. errors/gerror

    • Added ITextArgs interface and its implementation, mainly used for internationalization scenarios that require separate retrieval of text and args, enhancing internationalization support. #4597
    • Fixed serialization failure when gerror.Error text field contains quotes. #4449
  26. database/gredis

    • Supported retrieving raw Redis client, providing lower-level operation capabilities. #4306
  27. util/gpage

    • Marked as deprecated. It is recommended to use the ORM pagination feature or implement it yourself. #4230

Community Components

  1. contrib/registry/nacos

    • Updated nacos sdk to version 2.3.5, improving stability and performance. #4628
    • Added SetDefaultEndpoint and SetDefaultMetadata methods, providing more flexible configuration options. #4608
    • Upgraded nacos registry&config components. #4473
  2. contrib/drivers/pgsql

    • Added support for more field type conversions, enhancing PostgreSQL compatibility. #3737
    • Added support for converting array types numeric[] and decimal[] to Go []float64, improving array type handling. #4457, #4511
    • Fixed field overlap issue with same table names in pgsql multi-schema mode. #4375
    • Fixed merging of duplicate fields, especially key constraints. #4465
  3. contrib/drivers/gaussdb

    • Added gaussdb driver support, expanding database support range. #4563
  4. contrib/drivers/dm

    • Added Replace/InsertIgnore support and field type/length enhancements for dm database, improving DaMeng database support. #4541
    • Added WherePri support, simplifying primary key queries. #4157
    • Fixed support for multi-line SQL statements. #4163, #4164
  5. contrib/drivers/mysql

    • Fixed field duplication issue when same table name/column name exists in different MySQL/MariaDB databases. #4577
    • Fixed unit test issue for MySQL driver batch insert. #4456
  6. contrib/drivers/mssql

    • Updated tables SQL query to improve compatibility. #4170
    • Supported LastInsertId method. #4051
  7. contrib/drivers/oracle

    • Added Replace/LastInsertId functionality support for dm/pgsql/mssql/oracle, completing database features. #4547
  8. contrib/clickhouse

    • Optimized clickhouse driver implementation. #4499
    • Fixed issue where clickhouse cannot support int128/int256/uint128/uint256. #4370
  9. contrib/config/apollo

    • Fixed issue where gcfg config apollo cannot retrieve multiple namespace configurations and watch apollo change causing configuration loss. #4509

Development Tools

  1. gf run

    • Improved watch functionality to reload only on file write events, reducing unnecessary restarts. #4573, #4476
    • Fixed issue where AddSigHandlerShutdown doesn't work properly. #4441
  2. gf init

    • Improved command implementation with version retry and gofmt support to enhance project initialization experience. #4572, #4592
    • Fixed import errors caused by formatting. #4598
  3. gf gen ctrl

    • Improved and enhanced command implementation, improving controller code generation quality. #4325
    • Fixed by adding extra option for controller to control download behavior. #4435
  4. gf gen dao

    • Added wildcard pattern support for tables configuration, providing more flexible table name matching capabilities. #4632
    • Added broad matching support for tableEx attribute. #4453
    • Improved command implementation with removeFieldPrefix option support for more flexible field name prefix handling. #4243
    • Improved typeMap check logic. #4410
    • Fixed overlapping shardingPattern matching issue, ensuring correct sharding configuration. #4631
    • Fixed potential duplication issues during generation. #4268
    • Fixed issue with generating sharding dao in multiple shardingPattern tables. #4379
    • Fixed table ex matching bug fix. #4458
    • Fixed performance issue where command execution becomes very slow. #4498
    • Fixed unknown time zone error when generating code for clickhouse on windows platform. #4368
  5. gf gen service

    • Fixed missing versioned import path issue. #4242, #4638
  6. gf gen enums

    • Fixed incorrect output path when using relative paths. #4636
  7. gf build

    • Fixed gf build --dumpEnv command error. #4635
  8. gf env

    • Fixed command error. #4635
  9. Test Improvements

    • Enhanced integration tests for gen service command. #4645
    • Enhanced integration tests for gen pb command. #4644
    • Enhanced unit tests for fix command. #4643
    • Added unit tests for pack command. #4642
    • Added unit tests for gen enums command. #4641
    • Added unit tests for gen init command. #4640

Other Improvements

  1. Architecture Support

    • Added Loongson architecture (loong64) support, expanding platform compatibility. #4467
  2. Code Quality

    • Refactored interface{} to any, reflect.Ptr to reflect.Pointer, improving code modernization. #4395
  3. Dependency Management

    • Updated multiple dependency versions to enhance compatibility and security. #4380, #4237
    • Upgraded tablewriter to v1.0.9 and refactored table rendering logic. #4352
    • Upgraded nacos, redis, and other third-party libraries to the latest versions. #4241, #4215