GoFrame
GoFrame
is a modular, high-performance, production-grade Go foundational development framework. It implements comprehensive infrastructure and development toolchains, offering common foundational development modules such as cache, logging, queues, arrays, collections, containers, timers, command lines, memory locks, object pools, 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 and loosely-coupled design;
- Rich modules, ready to use;
- Simple and easy to use, easy to maintain;
- High code quality, high unit test coverage;
- Active community, with humble and approachable experts;
- Detailed development documentation and examples;
- Comprehensive local Chinese support;
- Designed for team and enterprise use;
Support Us
The OSC Best Open Source Project competition has begun. If you like GoFrame
, please cast your valuable vote for GoFrame
🙏 https://www.oschina.net/p/goframe
Change Log
Since GoFrame
is designed modularly, the update log for each version is introduced in the form of modules.
Important updates:
- Replaced all
json
operations within the framework from the standard library tojson-iterator/go
, improving operational efficiency. - Refactored the underlying design of the cache module, adding adapter design patterns, and adding memory and
Redis
adapter support. The memory adapter is provided by the default core module, while theRedis
adapter is provided by the community module: https://goframe.org/os/gcache/adapter - Added customizable validation rule registration feature: https://goframe.org/util/gvalid/customrule
Web Server
added examples for all configuration items: https://goframe.org/net/ghttp/config/exampleORM
addedSQL
cache adapter based onRedis
: https://goframe.org/database/gdb/model/cacheORM
added experimental feature for model associations: https://goframe.org/database/gdb/model/association- Improved automatic update feature of time in
ORM
, adding customizable time fields: https://goframe.org/database/gdb/model/auto-time - Error handling module added
Current
andNext
methods: https://goframe.org/errors/gerror/index
net
ghttp
Client
- Added
GetVar/PutVar/PostVar
requests methods, which allow sendingHTTP
requests and directly returning generic objects for convenient type conversion, making handling of returnedXML/JSON
results simpler: https://goframe.org/net/ghttp/client/demo/index - Added
SetProxy/Proxy
methods to set client proxy, supportingHTTP/Socket5
proxy types: https://goframe.org/net/ghttp/client/demo/proxy - Added
SetRedirectLimit/RedirectLimit
methods to set page redirect limit.
- Added
Request
- Added
ParseQuery
,ParseForm
methods to parse specified parameter types and bind them to a given object. - Added
GetHeader
method to get specifiedHeader
parameters. - Added
GetRemoteIp
method to get the IP of the requesting client. When using IP whitelist restrictions, useGetRemoteIp
instead ofGetClientIp
, as the latter can be forged throughHeader
. - Added
ReloadParam
method, often used in middleware processing when middleware modifies request parameters and calls this method to reparse them. - Added
GetRouterMap
method to get all routing parameters returned as amap
.
- Added
Response
- Renamed
Output
method toFlush
, used for writing buffer data to the client stream.
- Renamed
Server
Server
added examples for all configuration items: https://goframe.org/net/ghttp/config/example- Added
SessionCookieOutput
configuration to control whether to outputSessionId
toCookie
, enabled by default. - Improved route parsing to support
URI
with repeated/
symbols. Pprof
function routes supportDomain
binding.- Other minor improvements.
Cookie
- Added
SetHttpCookie
method to setCookie
based on a standard libraryhttp.Cookie
object. - Other functional improvements.
- Added
database
gdb
- Added experimental feature for model associations: https://goframe.org/database/gdb/model/association
- Improved automatic update feature of time, adding customizable time fields: https://goframe.org/database/gdb/model/auto-time
- Added
SQL
cache adapter based onRedis
: https://goframe.org/database/gdb/model/cache - Added automatic recognition mapping feature for input parameter key names and field names: https://goframe.org/database/gdb/senior
- Added
DB.HasTable
method to determine whether the current database contains the specified table. - Added
Model.HasField
method to determine whether the current table contains the specified field. - Added
Model.ScanList
method to intelligently bind the currentstruct
/slice
to the specifiedlist
corresponding attributes. - Added
Result.MapKeyValue
method to convert the currentResult
tomap[string]Value
type. - Added
Result.IsEmpty/Len/Size/ScanList
methods. - Added
ListItemValues
andListItemValuesUnique
methods to automatically get the values or properties with specified names in thelist
, returning them as aslice
. SQL
log content includes group name printing.- Improved
DataToMapDeep
method. - Other minor improvements.
gredis
- Added
TLS
feature support and configuration file support, https://goframe.org/database/gredis/config
- Added
container
gvar
- Added
Scan
andScanDeep
methods for automatic recognition and conversion ofstruct
/slice
. - Added
ListItemValues
andListItemValuesUnique
methods to automatically get the values or properties with specified names in thelist
, returning them as aslice
. - Added
MapStrAny
interface implementation method.
- Added
os
gcache
- Added
GetVar
method to get cached data and return it as a generic object. - Added
Update
method to only modify cache values without modifying expiration times. - Added
UpdateExpire
method to only modify cache expiration times without modifying values. - Refactored underlying design, adding adapter design patterns, and memory and
Redis
adapter support. The memory adapter is provided by the default core module, and theRedis
adapter is provided by the community module: https://goframe.org/os/gcache/adapter - Note, this module modification may have some method incompatibility, some methods added
error
parameter return, please review carefully when upgrading. Compilation will not pass. - Other functional improvements.
- Added
gfile
- Added
ScanDirFileFunc
method for recursive directory file traversal with a custom function handler. - Improved
Scan*
methods with added recursion level limits, default is100000
.
- Added
gfsnotify
- Removed
Watcher
object creation during module initialization, adjusted to runtime on-demand creation, with added concurrency safety controls.
- Removed
grpool
- Added
AddWithRecover
method for adding asynchronous tasks with a givenrecover
handling method, processingpanic
in tasks to prevent the entire process crash. - Solves the issue that
recover
can only capturepanic
in the currentgoroutine
, therefore a specificrecover
handling method can only be specified when creating asynchronous tasks.
- Added
gtime
- Added
ParseDuration
method with support for time unitd
representing days. - Improved `` method with support to create
gtime.Time
objects from strings, timestamps,time.Time
objects, https://goframe.org/os/gtime/time - Improved
Add/AddStr/ToLocation/ToZone/UTCLocal/AddDate/Truncate/Round
methods, these methods now create and return newgtime.Time
objects without altering the current object itself to ensure consistency with the standard librarytime.Time
logic and avoid confusion. - Other minor improvements.
- Added
gtimer
- Added
Reset
method for resetting timer task counts.
- Added
gfcache
- Removed the module, as its functionality was not particularly significant.
debug
gdebug
- Added
GoroutineId
method to get thegoroutine id
of the current execution, for debugging purposes only.
- Added
encoding
gjson
- Added
GetScan/GetScanDeep
methods. - Added
ToScan/ToScanDeep
methods. - Added
LoadContentType
method to createJson
operation objects based on specified content types. - Added
IsValidDataType
method to determine if a given data type is parseable. - Other improvements.
- Comprehensive unit testing.
- Added
gcompress
- Added
GzipFile/UnGzipFile
methods based ongzip
compression algorithm for file compression/decompression.
- Added
i18n
gi18n
- Added
TranslateFormat/TranslateFormatLang/Tf/Tfl
methods: https://goframe.org/i18n/gi18n/index
- Added
text
gstr
- Added
SnakeFirstUpperCase
method, which adds connectors before uppercase letters and does not process numbers, e.g.,SnakeFirstUpperCase("RGBCodeMd5")
will returnrgb_code_md5
.
- Added
util
gconv
- Added support for basic pointer type conversion.
- Added
Scan/ScanDeep
methods for automatic recognition and conversion ofStruct/[]Struct
. - Improved recursive layer handling in
MapDeep
method. - Other minor and performance improvements.
gutil
- Added
ListItemValues
andListItemValuesUnique
methods to automatically get values or properties with specified names in thelist
, returning them as aslice
. - Added
ItemValue
method to get key/property values of specifiedmap/*map/struct/*struct
types. - Added
MapOmitEmpty
method to filter empty values in amap
. - Added
SliceDelete
method for array item deletion. - Added
Try
method, which executes a given method through a closure and returnserror
if the methodpanic
, otherwise returnsnil
. - Improved
TryCatch(try func(), catch ...func(exception interface{}))
toTryCatch(try func(), catch ...func(exception error))
- Added
gvalid
- Added custom rule feature, allowing developers to register custom validation rules: https://goframe.org/util/gvalid/customrule
- Other functional improvements.
error
gerror
- Added
Current
method to get theerror
interface object of the current error level. - Added
Next
method to get the next level errorerror
interface object. If the next level does not exist, returnsnil
. - Documentation update: https://goframe.org/errors/gerror/index
- Added
Bug Fix
- Fixed
Unique
method issue ingarray
module. - Fixed
goroutine
leak issue inglog
during lazy initialization of the timer. - Fixed naming
Case
conversion issues ingstr
when names contain numbers and special characters. - Fixed
CORS
cross-domain settingHeader
detail issue inghttp
module. - Other BUG fixes: https://github.com/gogf/gf/issues?q=is%3Aissue+label%3Abug+is%3Aclosed