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
Swagger
tools and plugins, released separately.
tool chain
- The
gen model
command adds model generation support forpgsql/mssql/sqlite/oracle
. - The
gen model
command generates a public package variableColumns
for retrieving table field names.
net
ghttp
- Note: Starting from this version, the
Server
has the graceful restart feature disabled by default. Developers can enable it through the appropriate configuration options. - Improved
Client.Get
method 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/Context
for 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/GetUploadFiles
methods andUploadFile
type, greatly simplifying file upload processing logic: https://goframe.org/net/ghttp/client/demo/upload - Added
Request.GetPage
method 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
CORS
feature, improved cross-origin handling, fully conforming toW3C
specifications regarding theOPTIONS
request method: https://goframe.org/net/ghttp/cors - Added
Request
built-in variable to template view objects, allowing templates to obtain request parameters. As theGoFrame
framework's template engine uses a two-level cache design, it reducesIO
overhead 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 otherWebServer
libraries under the same logic. - Introduced an experimental
Plugin
feature 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
Server
log handling. - Enhanced unit testing.
- Note: Starting from this version, the
database
-
gdb
- Code refactoring and improvements, introducing
Driver
interface design for custom driver implementations by developers. AddedRegister
package method to allow developers to register custom database type drivers: https://goframe.org/database/gdb/driver - Added
GetArray
interface and implementation for retrieving data for specified field columns, returning an array: https://goframe.org/database/gdb/model/select - Added
InsertIgnore
interface and implementation for ignoring write conflicts during write operations, applicable only tomysql
database type: https://goframe.org/database/gdb/model/insert-save - Added
Schema
interface and implementation for dynamically switching and getting database objects with specified names: https://goframe.org/database/gdb/model/schema - Added
FieldsStr/FieldsExStr
model methods for obtaining table fields and returning them as strings: https://goframe.org/database/gdb/model/fields-retrieve - Added
LockUpdate/LockShared
model chainable methods for implementing pessimistic locking: https://goframe.org/database/gdb/model/lock - Improved support for the input method in
Where/Data
for update parameters, increasing flexibility: - Added
Array
method to query result objectResult
for obtaining values of specified fields, returning them in an array: https://goframe.org/database/gdb/result - Improved
OmitEmpty
method for filteringData
input parameters. If the givenData
parameter 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{}) error
interface method implementation to all container objects, used bygconv
for creating/setting object content based on arbitrary type variables. All container objects in theGoFrame
framework have implemented this interface. -
garray
- Added
RemoveValue
method for searching and removing elements based on values. - Added
FilterNil
method for traversing and removingnil
elements from an array. - Added
FilterEmpty
method 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/InsertAfter
methods with stricter validation, changing the original chain operation return value object toerror
return value. - Enhanced
Get/Remove/PopRand/PopLeft/PopRight/Rand
methods with stricter validation, adding afound
boolean return value to indicate if the method has data to return. If the array is empty or the operation is out of range,found
returnsfalse
. - Changed
Rands
method 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
int
type representing milliseconds, while the new version usestime.Duration
type 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
Rotation
log 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
LevelPrefixes
feature for customizing prefix names for log levels: https://goframe.org/os/glog/level - Added
SetLevelStr
method and feature to configure log levels using strings: - Introduced
SetDefaultLogger
package method for setting the global defaultLogger
object.
- Introduced
-
gres
- Improved resource content encoding design with a new compression algorithm, reducing resource file size, such as the original
15MB
website static resource files (css/js/html
, etc.) reduced to approximately4MB
after 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
toml
configuration 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
concat
built-in string concatenation method: https://goframe.org/os/gview/function/buildin - Enhanced unit testing.
- Added
-
gfile
- Improved
SelfPath
method for obtaining the current executable file path, increasing execution efficiency. - Enhanced
Join
method for connecting file paths, preventing redundant path connection symbols. - Improved execution efficiency of
GetContents
method, reducing memory usage. - Added
StrToSize
method for converting size strings to byte numbers. Size strings include10m
,5KB
,1.25Gib
, etc. - Added
ReadLines/ReadByteLines
methods for reading specified file content line by line with a given read callback function. - Enhanced unit testing.
- Improved
-
gtime
- Improved the implementation of
gtime.Time
object, unified string printed time format toY-m-d H:i:s
, such as2020-01-01 12:00:00
.
- Improved the implementation of
-
gcmd
- Added
strict
parameter 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
Remove
method 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
Watcher
object fails to create due to system reasons, itpanic
s directly.
- Improved package initialization method. If the default
-
gproc
- Improved
SearchBinaryPath
method. - Improved
Process.Kill
method for handling different behaviors onwindows
and*niux
platforms.
- 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
IsNil
method to determine if the given variable isnil
, potentially using reflection for judgment. - Added
IsEmpty
method 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
SetServerGraceful
method, managed uniformly throughServer
configuration.
- Added
gins
- Improved code structure for easier maintenance.
- Enhanced and improved unit testing.
gmvc
- Added
M
type as an alias for*gdb.Model
for convenience in toolchain auto-generated models containing theM
attribute.
- Added
text
gstr
- Added
HasPrefix/HasSuffix
methods. - Introduced
OctStr
method for converting octal strings to correspondingunicode
strings, such as Chinese. Commonly used ingRPC
underlying communication encoding. - Enhanced unit testing.
- Added
debug
gdebug
- Improved code structure for easier maintenance.
- Added
TestDataPath
method for obtaining the absolute path of thetestdata
directory in the current package for package unit tests.
util
-
gconv
- Improved
String
conversion method with built-in support fortime.Time/*time.Time/gtime.Time
types. - Enhanced
Map/Struct
conversion methods with additional detail handling for special scenarios. Continuous improvement based on extensive usage and feedback. - Updated
Struct
conversion method to supportUnmarshalValue(interface{}) error
interface. - Enhanced unit testing.
- Improved
-
grand
- Note: Incompatible adjustment, the original
Str
method renamed toS
for obtaining a random string of specified length along with thesymbol
parameter, to specify whether special visible characters can be returned randomly. - Added
Str
method for randomly retrieving a string of specified length from specified string characters, supportingunicode
strings, such as Chinese: https://goframe.org/util/grand/index - Added
Symbols
method 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
unicode
strings, such as Chinese.
- Length validation rules now support
Bug Fix
- Fixed the view object configuration issue in
Server
. - Fixed the issue where middleware in
Server
ignoredMiddleware.Next
method control in the event ofpanic
in middleware, causing authentication middleware to fail. - Resolved the
gudp.Server
packet loss problem when request packet size exceeds64bytes
, and the default buffer size has been adjusted to1024bytes
. Developers can customize buffer size. - Corrected
gfile.MTimeMillisecond
method to return the correct file modification millisecond timestamp. - Fixed
gconv.Int64
conversion support for negative numbers. - Various other fixes.
- For details, see: https://github.com/gogf/gf/issues?q=label%3Abug