Hello everyone! Thank you for waiting!
Since the last version release, more and more friends have joined the GoFrame family and provided many valuable suggestions and feedback. This version addresses most of these feedbacks, including most of the improvement suggestions and some new features, which is why this release took more than two months. GoFrame is very focused on code quality and sustainable maintainability. This version further refines the examples, comments, and unit test cases for most modules in the framework. Currently, there are about 1991 unit test cases with a code coverage of 71%, covering most of the main functions of all modules.
The GoFrame framework provides common, high-quality basic development modules, lightweight, modular, and high-performance. We recommend reading the framework source code to learn more details. This release has a few incompatible upgrades, often requiring batch replacements. The following change log is quite comprehensive, and it is recommended to read it carefully before upgrading.
This release marks the start of the next version development plan, and more friends are welcome to participate in open source contributions: https://github.com/gogf/gf/projects/8
Thank you for your support! Enjoy your GoFrame!
GoFrame
GoFrame(Go Frame) is a modular, high-performance, production-grade Golang basic development framework. It implements relatively complete infrastructure construction and development toolchain, providing commonly used basic development modules, such as: cache, log, queue, array, set, container, timer, command line, memory lock, object pool, configuration management, resource management, data validation, data encoding, scheduled tasks, database ORM, TCP/UDP components, process management/communication, etc. It also provides a series of core components for web service development, such as: Router, Cookie, Session, Middleware, service registration, template engine, etc., supporting features like hot restart, hot updates, domain binding, TLS/HTTPS, Rewrite, etc.
Features
- Modular, loosely coupled design;
- Rich modules, ready to use;
- Simple and easy to use, easy to maintain;
- Active community, modest and approachable experts;
- High code quality, high unit test coverage;
- Detailed development documentation and examples;
- Complete native Chinese support;
- More suitable for enterprise and team use;
Address
- Official Website: https://goframe.org
- Main Repository: https://github.com/gogf/gf
- Gitee: https://gitee.com/johng/gf
Change Log
From GoFrame v1.12 version, the minimum Golang runtime version required by the framework is v1.13. Since new versions of Golang are backward compatible, it is recommended to update to use the new version of Golang: https://golang.google.cn/dl/
This version also introduces support for the
Swaggertools and plugins, released separately.
tool chain
- The
gen modelcommand adds model generation support forpgsql/mssql/sqlite/oracle. - The
gen modelcommand generates a public package variableColumnsfor retrieving table field names.
net
ghttp- Note: Starting from this version, the
Serverhas the graceful restart feature disabled by default. Developers can enable it through the appropriate configuration options. - Improved
Client.Getmethod with optional request parameters. - Added chainable methods for
Client:Header,HeaderRaw,Cookie,ContentType,ContentJson,ContentXml,Timeout,BasicAuth,Ctx: https://goframe.org/net/ghttp/client/chain - Added context variable management methods
Request.GetCtx/GetCtxVar/SetCtxVar/Contextfor internal request context variables:- Custom Variables: https://goframe.org/net/ghttp/request/custom
- Context Variables: https://goframe.org/net/ghttp/request/context
- Added
Request.GetUploadFile/GetUploadFilesmethods andUploadFiletype, greatly simplifying file upload processing logic: https://goframe.org/net/ghttp/client/demo/upload - Added
Request.GetPagemethod for convenient pagination object retrieval:- Introduction: https://goframe.org/util/gpage/index
- Dynamic Pagination: https://goframe.org/util/gpage/dynamic
- Static Pagination: https://goframe.org/util/gpage/static
- Ajax Pagination: https://goframe.org/util/gpage/ajax
- URL Templates: https://goframe.org/util/gpage/template
- Custom Pagination: https://goframe.org/util/gpage/custom
- Improved
Response.Redirect*method with a customizable HTTP status code parameter for redirection. - Enhanced
CORSfeature, improved cross-origin handling, fully conforming toW3Cspecifications regarding theOPTIONSrequest method: https://goframe.org/net/ghttp/cors - Added
Requestbuilt-in variable to template view objects, allowing templates to obtain request parameters. As theGoFrameframework's template engine uses a two-level cache design, it reducesIOoverhead while improving execution efficiency. Even with a large number of built-in variables and methods added, extensive performance tests have shown that efficiency is 50% to 200% higher than otherWebServerlibraries under the same logic. - Introduced an experimental
Pluginfeature forServer. - Improved the underlying route storage and retrieval logic of
Server, optimized code, and enhanced efficiency. - Enhanced source location tracking for group route registration, allowing for precise location and prompt of duplicate route source locations when there are registration conflicts.
- Improved
Serverlog handling. - Enhanced unit testing.
- Note: Starting from this version, the
database
-
gdb- Code refactoring and improvements, introducing
Driverinterface design for custom driver implementations by developers. AddedRegisterpackage method to allow developers to register custom database type drivers: https://goframe.org/database/gdb/driver - Added
GetArrayinterface and implementation for retrieving data for specified field columns, returning an array: https://goframe.org/database/gdb/model/select - Added
InsertIgnoreinterface and implementation for ignoring write conflicts during write operations, applicable only tomysqldatabase type: https://goframe.org/database/gdb/model/insert-save - Added
Schemainterface and implementation for dynamically switching and getting database objects with specified names: https://goframe.org/database/gdb/model/schema - Added
FieldsStr/FieldsExStrmodel methods for obtaining table fields and returning them as strings: https://goframe.org/database/gdb/model/fields-retrieve - Added
LockUpdate/LockSharedmodel chainable methods for implementing pessimistic locking: https://goframe.org/database/gdb/model/lock - Improved support for the input method in
Where/Datafor update parameters, increasing flexibility: - Added
Arraymethod to query result objectResultfor obtaining values of specified fields, returning them in an array: https://goframe.org/database/gdb/result - Improved
OmitEmptymethod for filteringDatainput parameters. If the givenDataparameter is an empty time object, it will be filtered out. - Added default database connection pool parameter:
MaxIdleConns=10. - Various other improvements.
- Enhanced unit testing.
- Code refactoring and improvements, introducing
-
gredis- Increased/modified default database connection pool parameters:
MaxIdle=10,IdleTimeout=10s,MaxConnLifetime=30s,Wait=true. - Enhanced unit testing.
- Increased/modified default database connection pool parameters:
container
-
Added
UnmarshalValue(interface{}) errorinterface method implementation to all container objects, used bygconvfor creating/setting object content based on arbitrary type variables. All container objects in theGoFrameframework have implemented this interface. -
garray- Added
RemoveValuemethod for searching and removing elements based on values. - Added
FilterNilmethod for traversing and removingnilelements from an array. - Added
FilterEmptymethod for traversing and removing empty value elements from an array. Empty values include:0, nil, false, "", len(slice/map/chan) == 0. - Improved
Set/Fill/InsertBefore/InsertAftermethods with stricter validation, changing the original chain operation return value object toerrorreturn value. - Enhanced
Get/Remove/PopRand/PopLeft/PopRight/Randmethods with stricter validation, adding afoundboolean return value to indicate if the method has data to return. If the array is empty or the operation is out of range,foundreturnsfalse. - Changed
Randsmethod logic to ensure it returns a random array of the specified size. - Enhanced unit testing.
- Added
-
gpool- Adjusted the expiration time parameter type of the cache pool. The old version used
inttype representing milliseconds, while the new version usestime.Durationtype making time control more flexible. - Internal code optimization and performance improvement.
- Enhanced unit testing.
- Improved annotations.
- Adjusted the expiration time parameter type of the cache pool. The old version used
os
-
glog- Introduced
Rotationlog rolling feature, with options for log splitting based on file size or expiration time, supporting the limit of split file numbers, automatic compression of split files, customizable compression levels (1-9), and support for cleaning up expired split files: https://goframe.org/os/glog/rotate - Added
LevelPrefixesfeature for customizing prefix names for log levels: https://goframe.org/os/glog/level - Added
SetLevelStrmethod and feature to configure log levels using strings: - Introduced
SetDefaultLoggerpackage method for setting the global defaultLoggerobject.
- Introduced
-
gres- Improved resource content encoding design with a new compression algorithm, reducing resource file size, such as the original
15MBwebsite static resource files (css/js/html, etc.) reduced to approximately4MBafter packaging: https://goframe.org/os/gres/index - Note: This improvement is not compatible with the old version and requires re-packing of existing resource files.
- Enhanced unit testing.
- Improved resource content encoding design with a new compression algorithm, reducing resource file size, such as the original
-
gcfg- Removed atomic concurrency safety control for configuration object attributes, changed to ordinary variable types. Since configuration management is one of the most used modules, high efficiency in design and method implementation is ensured.
- Significant adjustment to singleton objects: To facilitate the use of configuration files in multi-file scenarios and improve development efficiency, when the
tomlconfiguration file corresponding to the given singleton name exists in the configuration directory, the default configuration file of the singleton object is automatically set to this file. For example, the singleton object obtained byg.Cfg("redis")will default to retrieving and setting the default configuration file asredis.toml. If the file does not exist, the default configuration file (config.toml) is used: https://goframe.org/net/ghttp/config - Enhanced unit testing.
-
gview- Added
concatbuilt-in string concatenation method: https://goframe.org/os/gview/function/buildin - Enhanced unit testing.
- Added
-
gfile- Improved
SelfPathmethod for obtaining the current executable file path, increasing execution efficiency. - Enhanced
Joinmethod for connecting file paths, preventing redundant path connection symbols. - Improved execution efficiency of
GetContentsmethod, reducing memory usage. - Added
StrToSizemethod for converting size strings to byte numbers. Size strings include10m,5KB,1.25Gib, etc. - Added
ReadLines/ReadByteLinesmethods for reading specified file content line by line with a given read callback function. - Enhanced unit testing.
- Improved
-
gtime- Improved the implementation of
gtime.Timeobject, unified string printed time format toY-m-d H:i:s, such as2020-01-01 12:00:00.
- Improved the implementation of
-
gcmd- Added
strictparameter to command-line parsing methods for determining whether the current parsing is strict. In strict parsing, if illegal options are given, parsing stops and returns an error. By default, it is non-strict parsing.
- Added
-
genv- Improved
Removemethod for deleting environment variable key-value pairs, adding the ability to delete multiple key-value pair environment variables.
- Improved
-
gfpool- Improved code implementation, increasing efficiency.
- Enhanced unit testing.
-
gfsnotify- Improved package initialization method. If the default
Watcherobject fails to create due to system reasons, itpanics directly.
- Improved package initialization method. If the default
-
gproc- Improved
SearchBinaryPathmethod. - Improved
Process.Killmethod for handling different behaviors onwindowsand*niuxplatforms.
- Improved
encoding
gjson- Code improvements, enhanced annotations, added numerous code examples.
- Documentation updates:
- Introduction: https://goframe.org/encoding/gjson/index
- Object Creation: https://goframe.org/encoding/gjson/object
- Level Access: https://goframe.org/encoding/gjson/pattern
- Struct Conversion: https://goframe.org/encoding/gjson/conversion-struct
- Dynamic Creation/Modification: https://goframe.org/encoding/gjson/dataset
- Data Format Conversion: https://goframe.org/encoding/gjson/conversion-format
frame
g- Added
IsNilmethod to determine if the given variable isnil, potentially using reflection for judgment. - Added
IsEmptymethod to determine if the given variable isempty. This method primarily uses assertion but may use reflection for judgment. Empty values include:0, nil, false, "", len(slice/map/chan) == 0. - Deprecated
SetServerGracefulmethod, managed uniformly throughServerconfiguration.
- Added
gins- Improved code structure for easier maintenance.
- Enhanced and improved unit testing.
gmvc- Added
Mtype as an alias for*gdb.Modelfor convenience in toolchain auto-generated models containing theMattribute.
- Added
text
gstr- Added
HasPrefix/HasSuffixmethods. - Introduced
OctStrmethod for converting octal strings to correspondingunicodestrings, such as Chinese. Commonly used ingRPCunderlying communication encoding. - Enhanced unit testing.
- Added
debug
gdebug- Improved code structure for easier maintenance.
- Added
TestDataPathmethod for obtaining the absolute path of thetestdatadirectory in the current package for package unit tests.
util
-
gconv- Improved
Stringconversion method with built-in support fortime.Time/*time.Time/gtime.Timetypes. - Enhanced
Map/Structconversion methods with additional detail handling for special scenarios. Continuous improvement based on extensive usage and feedback. - Updated
Structconversion method to supportUnmarshalValue(interface{}) errorinterface. - Enhanced unit testing.
- Improved
-
grand- Note: Incompatible adjustment, the original
Strmethod renamed toSfor obtaining a random string of specified length along with thesymbolparameter, to specify whether special visible characters can be returned randomly. - Added
Strmethod for randomly retrieving a string of specified length from specified string characters, supportingunicodestrings, such as Chinese: https://goframe.org/util/grand/index - Added
Symbolsmethod for randomly returning special visible characters for specified purposes: https://goframe.org/util/grand/index - Enhanced unit testing.
- Note: Incompatible adjustment, the original
-
gvalid- Length validation rules now support
unicodestrings, such as Chinese.
- Length validation rules now support
Bug Fix
- Fixed the view object configuration issue in
Server. - Fixed the issue where middleware in
ServerignoredMiddleware.Nextmethod control in the event ofpanicin middleware, causing authentication middleware to fail. - Resolved the
gudp.Serverpacket loss problem when request packet size exceeds64bytes, and the default buffer size has been adjusted to1024bytes. Developers can customize buffer size. - Corrected
gfile.MTimeMillisecondmethod to return the correct file modification millisecond timestamp. - Fixed
gconv.Int64conversion support for negative numbers. - Various other fixes.
- For details, see: https://github.com/gogf/gf/issues?q=label%3Abug