From ee2cf92479a0575e07d3812d18b7eaea4fe10bbe Mon Sep 17 00:00:00 2001 From: John Guo Date: Mon, 4 Dec 2023 19:34:48 +0800 Subject: [PATCH] Version/v2.6.0 beta (#3183) --- cmd/gf/go.mod | 14 +++--- cmd/gf/go.sum | 14 ------ cmd/gf/internal/cmd/cmd_run.go | 16 +++--- cmd/gf/internal/cmd/genctrl/genctrl.go | 2 +- contrib/config/apollo/go.mod | 2 +- contrib/config/consul/go.mod | 2 +- contrib/config/kubecm/go.mod | 2 +- contrib/config/nacos/go.mod | 2 +- contrib/config/polaris/go.mod | 2 +- contrib/drivers/clickhouse/go.mod | 2 +- contrib/drivers/dm/go.mod | 2 +- contrib/drivers/mssql/go.mod | 2 +- contrib/drivers/mysql/go.mod | 2 +- contrib/drivers/oracle/go.mod | 2 +- contrib/drivers/pgsql/go.mod | 2 +- contrib/drivers/sqlite/go.mod | 2 +- contrib/drivers/sqlitecgo/go.mod | 2 +- contrib/nosql/redis/go.mod | 2 +- contrib/registry/etcd/go.mod | 2 +- contrib/registry/file/go.mod | 2 +- contrib/registry/nacos/go.mod | 2 +- contrib/registry/polaris/go.mod | 2 +- contrib/registry/zookeeper/go.mod | 2 +- contrib/rpc/grpcx/go.mod | 4 +- contrib/rpc/grpcx/grpcx_grpc_server_config.go | 49 ++++++++++++++----- contrib/sdk/httpclient/go.mod | 2 +- contrib/trace/jaeger/go.mod | 2 +- contrib/trace/otlpgrpc/go.mod | 2 +- contrib/trace/otlphttp/go.mod | 2 +- errors/gerror/gerror_api_option.go | 10 +++- errors/gerror/gerror_z_unit_test.go | 2 +- example/go.mod | 28 +++++------ net/ghttp/ghttp.go | 2 +- os/gcfg/gcfg_z_example_test.go | 19 +++++++ os/glog/glog_logger.go | 4 +- os/glog/glog_logger_handler.go | 2 +- os/gsession/gsession.go | 2 +- util/gvalid/gvalid_error.go | 2 +- version.go | 2 +- 39 files changed, 128 insertions(+), 90 deletions(-) diff --git a/cmd/gf/go.mod b/cmd/gf/go.mod index 48579f385..07c466123 100644 --- a/cmd/gf/go.mod +++ b/cmd/gf/go.mod @@ -3,13 +3,13 @@ module github.com/gogf/gf/cmd/gf/v2 go 1.18 require ( - github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.5.7 - github.com/gogf/gf/contrib/drivers/mssql/v2 v2.5.7 - github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.7 - github.com/gogf/gf/contrib/drivers/oracle/v2 v2.5.7 - github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.5.7 - github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.5.7 - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.6.0-beta + github.com/gogf/gf/contrib/drivers/mssql/v2 v2.6.0-beta + github.com/gogf/gf/contrib/drivers/mysql/v2 v2.6.0-beta + github.com/gogf/gf/contrib/drivers/oracle/v2 v2.6.0-beta + github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.6.0-beta + github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.6.0-beta + github.com/gogf/gf/v2 v2.6.0-beta github.com/minio/selfupdate v0.6.0 github.com/olekukonko/tablewriter v0.0.5 golang.org/x/mod v0.9.0 diff --git a/cmd/gf/go.sum b/cmd/gf/go.sum index 533674fa5..bb5f8a4a8 100644 --- a/cmd/gf/go.sum +++ b/cmd/gf/go.sum @@ -38,20 +38,6 @@ github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiU github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= -github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.5.6 h1:yziPSf9AycEWphv9WiNjcRAVPOJtUauMMvP6pHQB4jY= -github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.5.6/go.mod h1:yOlpwhFXgW+P2sf4goA20PUtxdVLliBx4dJRyJeOtto= -github.com/gogf/gf/contrib/drivers/mssql/v2 v2.5.6 h1:LGQIe5IvYVr4hZ/vUAFiqWssxE7QeILyVPJ9swo1Cmk= -github.com/gogf/gf/contrib/drivers/mssql/v2 v2.5.6/go.mod h1:EcF8v8jqCV61/YqN6DXxdo3kh8waGmEj6WpFqbLkkrM= -github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.6 h1:oR9F4LVoKa/fjf/o6Y/CQRNiYy35Bszo07WwvMWYMxo= -github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.6/go.mod h1:gvHSRqCpv2c+N0gDHsEldHgU/yM9tcCBdIEKZ32/TaE= -github.com/gogf/gf/contrib/drivers/oracle/v2 v2.5.6 h1:3Y3lEoO9SoG1AmfaKjgTsDt93+T2q/qTMog8wBvIIGM= -github.com/gogf/gf/contrib/drivers/oracle/v2 v2.5.6/go.mod h1:cR3lFoU6ZtSaMQ3DpCJwWnYW6EvHPYGGeqv/kzgH4gw= -github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.5.6 h1:0WHVzqITqIBu/NNPXt3tN2eiWAGiNjs9sg6wh+WbUvY= -github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.5.6/go.mod h1:qZCTNQ0n2gHcuBwM9wUl3pelync3xK0gTnChJZD6f0I= -github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.5.6 h1:6clfLvFoHXHdw+skmXg4yxw+cLwgAG8gRiS/6f9Y9Xc= -github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.5.6/go.mod h1:QV6Rrj+4G4OaJVkP9XXRZ1LWL+ls6qH7ebeMcxsulqA= -github.com/gogf/gf/v2 v2.5.6 h1:a1UK1yUP3s+l+vPxmV91+8gTarAP9b1IEOw0W7LNl6E= -github.com/gogf/gf/v2 v2.5.6/go.mod h1:17K/gBYrp0bHGC3XYC7bSPoywmZ6MrZHrZakTfh4eIQ= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= diff --git a/cmd/gf/internal/cmd/cmd_run.go b/cmd/gf/internal/cmd/cmd_run.go index 1771f81ca..337ba7aa6 100644 --- a/cmd/gf/internal/cmd/cmd_run.go +++ b/cmd/gf/internal/cmd/cmd_run.go @@ -82,11 +82,11 @@ func init() { type ( cRunInput struct { g.Meta `name:"run"` - File string `name:"FILE" arg:"true" brief:"{cRunFileBrief}" v:"required"` - Path string `name:"path" short:"p" brief:"{cRunPathBrief}" d:"./"` - Extra string `name:"extra" short:"e" brief:"{cRunExtraBrief}"` - Args string `name:"args" short:"a" brief:"{cRunArgsBrief}"` - WatchPaths string `name:"watchPaths" short:"w" brief:"{cRunWatchPathsBrief}"` + File string `name:"FILE" arg:"true" brief:"{cRunFileBrief}" v:"required"` + Path string `name:"path" short:"p" brief:"{cRunPathBrief}" d:"./"` + Extra string `name:"extra" short:"e" brief:"{cRunExtraBrief}"` + Args string `name:"args" short:"a" brief:"{cRunArgsBrief}"` + WatchPaths []string `name:"watchPaths" short:"w" brief:"{cRunWatchPathsBrief}"` } cRunOutput struct{} ) @@ -97,12 +97,16 @@ func (c cRun) Index(ctx context.Context, in cRunInput) (out *cRunOutput, err err mlog.Fatalf(`command "go" not found in your environment, please install golang first to proceed this command`) } + if len(in.WatchPaths) == 1 { + in.WatchPaths = strings.Split(in.WatchPaths[0], ",") + } + app := &cRunApp{ File: in.File, Path: in.Path, Options: in.Extra, Args: in.Args, - WatchPaths: strings.Split(in.WatchPaths, ","), + WatchPaths: in.WatchPaths, } dirty := gtype.NewBool() _, err = gfsnotify.Add(gfile.RealPath("."), func(event *gfsnotify.Event) { diff --git a/cmd/gf/internal/cmd/genctrl/genctrl.go b/cmd/gf/internal/cmd/genctrl/genctrl.go index a651a3d8c..d7d4b4bdf 100644 --- a/cmd/gf/internal/cmd/genctrl/genctrl.go +++ b/cmd/gf/internal/cmd/genctrl/genctrl.go @@ -74,7 +74,7 @@ type ( SdkStdVersion bool `short:"v" name:"sdkStdVersion" brief:"{CGenCtrlBriefSdkStdVersion}" orphan:"true"` SdkNoV1 bool `short:"n" name:"sdkNoV1" brief:"{CGenCtrlBriefSdkNoV1}" orphan:"true"` Clear bool `short:"c" name:"clear" brief:"{CGenCtrlBriefClear}" orphan:"true"` - Merge bool `short:"m" name:"merge" brief:"{CGenCtrlControllerMerge}" orphan:"true"` + Merge bool `short:"m" name:"merge" brief:"{CGenCtrlControllerMerge}" orphan:"true"` } CGenCtrlOutput struct{} ) diff --git a/contrib/config/apollo/go.mod b/contrib/config/apollo/go.mod index 660c47820..1c2171cdb 100644 --- a/contrib/config/apollo/go.mod +++ b/contrib/config/apollo/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/apolloconfig/agollo/v4 v4.3.1 - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta ) require ( diff --git a/contrib/config/consul/go.mod b/contrib/config/consul/go.mod index bf1c2fcb4..907314f91 100644 --- a/contrib/config/consul/go.mod +++ b/contrib/config/consul/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/consul/v2 go 1.19 require ( - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta github.com/hashicorp/consul/api v1.24.0 github.com/hashicorp/go-cleanhttp v0.5.2 ) diff --git a/contrib/config/kubecm/go.mod b/contrib/config/kubecm/go.mod index 3f9770b1b..cd7162dfc 100644 --- a/contrib/config/kubecm/go.mod +++ b/contrib/config/kubecm/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/kubecm/v2 go 1.19 require ( - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta k8s.io/api v0.27.4 k8s.io/apimachinery v0.27.4 k8s.io/client-go v0.27.4 diff --git a/contrib/config/nacos/go.mod b/contrib/config/nacos/go.mod index 48b6c46f4..bbc4a4461 100644 --- a/contrib/config/nacos/go.mod +++ b/contrib/config/nacos/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/nacos/v2 go 1.18 require ( - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta github.com/nacos-group/nacos-sdk-go v1.1.4 ) diff --git a/contrib/config/polaris/go.mod b/contrib/config/polaris/go.mod index 51ae7e0c9..00b065558 100644 --- a/contrib/config/polaris/go.mod +++ b/contrib/config/polaris/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/polaris/v2 go 1.18 require ( - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta github.com/polarismesh/polaris-go v1.5.5 ) diff --git a/contrib/drivers/clickhouse/go.mod b/contrib/drivers/clickhouse/go.mod index b9a902dbd..ac63af729 100644 --- a/contrib/drivers/clickhouse/go.mod +++ b/contrib/drivers/clickhouse/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/ClickHouse/clickhouse-go/v2 v2.0.15 - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta github.com/google/uuid v1.3.0 github.com/shopspring/decimal v1.3.1 ) diff --git a/contrib/drivers/dm/go.mod b/contrib/drivers/dm/go.mod index 2f187647a..1b87b9593 100644 --- a/contrib/drivers/dm/go.mod +++ b/contrib/drivers/dm/go.mod @@ -6,7 +6,7 @@ replace github.com/gogf/gf/v2 => ../../../ require ( gitee.com/chunanyong/dm v1.8.12 - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta ) require ( diff --git a/contrib/drivers/mssql/go.mod b/contrib/drivers/mssql/go.mod index 24b42a513..f910c220e 100644 --- a/contrib/drivers/mssql/go.mod +++ b/contrib/drivers/mssql/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/denisenkom/go-mssqldb v0.12.3 - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta ) require ( diff --git a/contrib/drivers/mysql/go.mod b/contrib/drivers/mysql/go.mod index 21db76fdd..618c6417c 100644 --- a/contrib/drivers/mysql/go.mod +++ b/contrib/drivers/mysql/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/go-sql-driver/mysql v1.7.1 - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta ) require ( diff --git a/contrib/drivers/oracle/go.mod b/contrib/drivers/oracle/go.mod index d71523e10..1dad9a248 100644 --- a/contrib/drivers/oracle/go.mod +++ b/contrib/drivers/oracle/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/oracle/v2 go 1.18 require ( - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta github.com/sijms/go-ora/v2 v2.7.10 ) diff --git a/contrib/drivers/pgsql/go.mod b/contrib/drivers/pgsql/go.mod index 5da1ae1ef..b6f82b5e4 100644 --- a/contrib/drivers/pgsql/go.mod +++ b/contrib/drivers/pgsql/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/pgsql/v2 go 1.18 require ( - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta github.com/lib/pq v1.10.9 ) diff --git a/contrib/drivers/sqlite/go.mod b/contrib/drivers/sqlite/go.mod index acf2067b5..840fa0764 100644 --- a/contrib/drivers/sqlite/go.mod +++ b/contrib/drivers/sqlite/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/glebarez/go-sqlite v1.21.2 - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta ) require ( diff --git a/contrib/drivers/sqlitecgo/go.mod b/contrib/drivers/sqlitecgo/go.mod index ee53a450d..392f7e381 100644 --- a/contrib/drivers/sqlitecgo/go.mod +++ b/contrib/drivers/sqlitecgo/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/sqlitecgo/v2 go 1.18 require ( - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta github.com/mattn/go-sqlite3 v1.14.17 ) diff --git a/contrib/nosql/redis/go.mod b/contrib/nosql/redis/go.mod index 0284ad9f7..f7029eb4e 100644 --- a/contrib/nosql/redis/go.mod +++ b/contrib/nosql/redis/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/nosql/redis/v2 go 1.18 require ( - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta github.com/redis/go-redis/v9 v9.2.1 go.opentelemetry.io/otel v1.14.0 go.opentelemetry.io/otel/trace v1.14.0 diff --git a/contrib/registry/etcd/go.mod b/contrib/registry/etcd/go.mod index 159a9c210..a036cd9ad 100644 --- a/contrib/registry/etcd/go.mod +++ b/contrib/registry/etcd/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/etcd/v2 go 1.18 require ( - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta go.etcd.io/etcd/client/v3 v3.5.7 ) diff --git a/contrib/registry/file/go.mod b/contrib/registry/file/go.mod index 83b0ca1c5..1f950ab51 100644 --- a/contrib/registry/file/go.mod +++ b/contrib/registry/file/go.mod @@ -2,7 +2,7 @@ module github.com/gogf/gf/contrib/registry/file/v2 go 1.18 -require github.com/gogf/gf/v2 v2.5.7 +require github.com/gogf/gf/v2 v2.6.0-beta require ( github.com/BurntSushi/toml v1.2.0 // indirect diff --git a/contrib/registry/nacos/go.mod b/contrib/registry/nacos/go.mod index bddf9aaa5..0055ac90c 100644 --- a/contrib/registry/nacos/go.mod +++ b/contrib/registry/nacos/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/nacos/v2 go 1.18 require ( - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta github.com/joy999/nacos-sdk-go v0.0.0-20231120071639-10a34b3e7288 ) diff --git a/contrib/registry/polaris/go.mod b/contrib/registry/polaris/go.mod index 92c0663d2..cbc70976e 100644 --- a/contrib/registry/polaris/go.mod +++ b/contrib/registry/polaris/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/polaris/v2 go 1.18 require ( - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta github.com/polarismesh/polaris-go v1.5.5 ) diff --git a/contrib/registry/zookeeper/go.mod b/contrib/registry/zookeeper/go.mod index 61ebd46a1..fad7faa5a 100644 --- a/contrib/registry/zookeeper/go.mod +++ b/contrib/registry/zookeeper/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/go-zookeeper/zk v1.0.3 - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta golang.org/x/sync v0.4.0 ) diff --git a/contrib/rpc/grpcx/go.mod b/contrib/rpc/grpcx/go.mod index eb893110e..593fe0198 100644 --- a/contrib/rpc/grpcx/go.mod +++ b/contrib/rpc/grpcx/go.mod @@ -3,8 +3,8 @@ module github.com/gogf/gf/contrib/rpc/grpcx/v2 go 1.18 require ( - github.com/gogf/gf/contrib/registry/file/v2 v2.5.7 - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/contrib/registry/file/v2 v2.6.0-beta + github.com/gogf/gf/v2 v2.6.0-beta go.opentelemetry.io/otel v1.14.0 go.opentelemetry.io/otel/trace v1.14.0 google.golang.org/grpc v1.57.2 diff --git a/contrib/rpc/grpcx/grpcx_grpc_server_config.go b/contrib/rpc/grpcx/grpcx_grpc_server_config.go index bcc24b121..47ab655da 100644 --- a/contrib/rpc/grpcx/grpcx_grpc_server_config.go +++ b/contrib/rpc/grpcx/grpcx_grpc_server_config.go @@ -8,7 +8,6 @@ package grpcx import ( "context" - "google.golang.org/grpc" "github.com/gogf/gf/v2/frame/g" @@ -18,18 +17,41 @@ import ( // GrpcServerConfig is the configuration for server. type GrpcServerConfig struct { - Address string // (optional) Single address for server listening, use `:0` or `ip:0` to serve random port. - Name string // (optional) Name for current service. - Logger *glog.Logger // (optional) Logger for server. - LogPath string // (optional) LogPath specifies the directory for storing logging files. - LogStdout bool // (optional) LogStdout specifies whether printing logging content to stdout. - ErrorStack bool // (optional) ErrorStack specifies whether logging stack information when error. - ErrorLogEnabled bool // (optional) ErrorLogEnabled enables error logging content to files. - ErrorLogPattern string // (optional) ErrorLogPattern specifies the error log file pattern like: error-{Ymd}.log - AccessLogEnabled bool // (optional) AccessLogEnabled enables access logging content to file. - AccessLogPattern string // (optional) AccessLogPattern specifies the error log file pattern like: access-{Ymd}.log - Endpoints []string // (optional) Endpoints are custom endpoints for service register, it uses Address if empty. - Options []grpc.ServerOption // (optional) GRPC Server options. + // (optional) Name for current service. + Name string + + // (optional) Single address for server listening, use `:0` or `ip:0` to serve random port. + Address string + + // (optional) Logger for server. + Logger *glog.Logger + + // (optional) LogPath specifies the directory for storing logging files. + LogPath string + + // (optional) LogStdout specifies whether printing logging content to stdout. + LogStdout bool + + // (optional) ErrorStack specifies whether logging stack information when error. + ErrorStack bool + + // (optional) ErrorLogEnabled enables error logging content to files. + ErrorLogEnabled bool + + // (optional) ErrorLogPattern specifies the error log file pattern like: error-{Ymd}.log + ErrorLogPattern string + + // (optional) AccessLogEnabled enables access logging content to file. + AccessLogEnabled bool + + // (optional) AccessLogPattern specifies the error log file pattern like: access-{Ymd}.log + AccessLogPattern string + + // (optional) Endpoints are custom endpoints for service register, it uses Address if empty. + Endpoints []string + + // (optional) GRPC Server options. + Options []grpc.ServerOption } // NewConfig creates and returns a ServerConfig object with default configurations. @@ -51,6 +73,7 @@ func (s modServer) NewConfig() *GrpcServerConfig { ) // Reading configuration file and updating the configured keys. if g.Cfg().Available(ctx) { + // Server attributes configuration. if err = g.Cfg().MustGet(ctx, configNodeNameGrpcServer).Struct(&config); err != nil { g.Log().Error(ctx, err) } diff --git a/contrib/sdk/httpclient/go.mod b/contrib/sdk/httpclient/go.mod index f848861ae..5de6891c4 100644 --- a/contrib/sdk/httpclient/go.mod +++ b/contrib/sdk/httpclient/go.mod @@ -2,7 +2,7 @@ module github.com/gogf/gf/contrib/sdk/httpclient/v2 go 1.18 -require github.com/gogf/gf/v2 v2.5.7 +require github.com/gogf/gf/v2 v2.6.0-beta require ( github.com/BurntSushi/toml v1.2.0 // indirect diff --git a/contrib/trace/jaeger/go.mod b/contrib/trace/jaeger/go.mod index dd1ad15fc..0de613f64 100644 --- a/contrib/trace/jaeger/go.mod +++ b/contrib/trace/jaeger/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/trace/jaeger/v2 go 1.18 require ( - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta go.opentelemetry.io/otel v1.14.0 go.opentelemetry.io/otel/exporters/jaeger v1.14.0 go.opentelemetry.io/otel/sdk v1.14.0 diff --git a/contrib/trace/otlpgrpc/go.mod b/contrib/trace/otlpgrpc/go.mod index 867c1e998..7962c8a25 100644 --- a/contrib/trace/otlpgrpc/go.mod +++ b/contrib/trace/otlpgrpc/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/trace/otlpgrpc/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta go.opentelemetry.io/otel v1.19.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 diff --git a/contrib/trace/otlphttp/go.mod b/contrib/trace/otlphttp/go.mod index 83d998684..3c110331d 100644 --- a/contrib/trace/otlphttp/go.mod +++ b/contrib/trace/otlphttp/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/trace/otlphttp/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/v2 v2.6.0-beta go.opentelemetry.io/otel v1.19.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 diff --git a/errors/gerror/gerror_api_option.go b/errors/gerror/gerror_api_option.go index 33ed881f7..4ac7f1d93 100644 --- a/errors/gerror/gerror_api_option.go +++ b/errors/gerror/gerror_api_option.go @@ -16,9 +16,9 @@ type Option struct { Code gcode.Code // Error code if necessary. } -// NewOption creates and returns a custom error with Option. +// NewWithOption creates and returns a custom error with Option. // It is the senior usage for creating error, which is often used internally in framework. -func NewOption(option Option) error { +func NewWithOption(option Option) error { err := &Error{ error: option.Error, text: option.Text, @@ -29,3 +29,9 @@ func NewOption(option Option) error { } return err } + +// NewOption creates and returns a custom error with Option. +// Deprecated: use NewWithOption instead. +func NewOption(option Option) error { + return NewWithOption(option) +} diff --git a/errors/gerror/gerror_z_unit_test.go b/errors/gerror/gerror_z_unit_test.go index 7ea90bd93..71a1b4fc7 100644 --- a/errors/gerror/gerror_z_unit_test.go +++ b/errors/gerror/gerror_z_unit_test.go @@ -442,7 +442,7 @@ func Test_HashCode(t *testing.T) { func Test_NewOption(t *testing.T) { gtest.C(t, func(t *gtest.T) { - t.AssertNE(gerror.NewOption(gerror.Option{ + t.AssertNE(gerror.NewWithOption(gerror.Option{ Error: errors.New("NewOptionError"), Stack: true, Text: "Text", diff --git a/example/go.mod b/example/go.mod index c95a2700d..26a4c0eff 100644 --- a/example/go.mod +++ b/example/go.mod @@ -3,21 +3,21 @@ module github.com/gogf/gf/example go 1.20 require ( - github.com/gogf/gf/contrib/config/apollo/v2 v2.5.7 - github.com/gogf/gf/contrib/config/consul/v2 v2.5.7 - github.com/gogf/gf/contrib/config/kubecm/v2 v2.5.7 - github.com/gogf/gf/contrib/config/nacos/v2 v2.5.7 - github.com/gogf/gf/contrib/config/polaris/v2 v2.5.7 - github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.7 - github.com/gogf/gf/contrib/nosql/redis/v2 v2.5.7 - github.com/gogf/gf/contrib/registry/etcd/v2 v2.5.7 - github.com/gogf/gf/contrib/registry/file/v2 v2.5.7 + github.com/gogf/gf/contrib/config/apollo/v2 v2.6.0-beta + github.com/gogf/gf/contrib/config/consul/v2 v2.6.0-beta + github.com/gogf/gf/contrib/config/kubecm/v2 v2.6.0-beta + github.com/gogf/gf/contrib/config/nacos/v2 v2.6.0-beta + github.com/gogf/gf/contrib/config/polaris/v2 v2.6.0-beta + github.com/gogf/gf/contrib/drivers/mysql/v2 v2.6.0-beta + github.com/gogf/gf/contrib/nosql/redis/v2 v2.6.0-beta + github.com/gogf/gf/contrib/registry/etcd/v2 v2.6.0-beta + github.com/gogf/gf/contrib/registry/file/v2 v2.6.0-beta github.com/gogf/gf/contrib/registry/nacos/v2 v2.5.6 - github.com/gogf/gf/contrib/registry/polaris/v2 v2.5.7 - github.com/gogf/gf/contrib/rpc/grpcx/v2 v2.5.7 - github.com/gogf/gf/contrib/trace/otlpgrpc/v2 v2.5.7 - github.com/gogf/gf/contrib/trace/otlphttp/v2 v2.5.7 - github.com/gogf/gf/v2 v2.5.7 + github.com/gogf/gf/contrib/registry/polaris/v2 v2.6.0-beta + github.com/gogf/gf/contrib/rpc/grpcx/v2 v2.6.0-beta + github.com/gogf/gf/contrib/trace/otlpgrpc/v2 v2.6.0-beta + github.com/gogf/gf/contrib/trace/otlphttp/v2 v2.6.0-beta + github.com/gogf/gf/v2 v2.6.0-beta github.com/hashicorp/consul/api v1.24.0 github.com/hashicorp/go-cleanhttp v0.5.2 github.com/nacos-group/nacos-sdk-go v1.1.4 diff --git a/net/ghttp/ghttp.go b/net/ghttp/ghttp.go index 3d1204271..6d53f66d6 100644 --- a/net/ghttp/ghttp.go +++ b/net/ghttp/ghttp.go @@ -205,7 +205,7 @@ var ( ) var ( - ErrNeedJsonBody = gerror.NewOption(gerror.Option{ + ErrNeedJsonBody = gerror.NewWithOption(gerror.Option{ Text: "the request body content should be JSON format", Code: gcode.CodeInvalidRequest, }) diff --git a/os/gcfg/gcfg_z_example_test.go b/os/gcfg/gcfg_z_example_test.go index a64a2e4ca..d45d74e6a 100644 --- a/os/gcfg/gcfg_z_example_test.go +++ b/os/gcfg/gcfg_z_example_test.go @@ -11,6 +11,7 @@ import ( "os" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gcfg" "github.com/gogf/gf/v2/os/gcmd" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/genv" @@ -64,3 +65,21 @@ func ExampleConfig_GetWithCmd() { // cmd: // cmd:yes } + +func Example_NewWithAdapter() { + var ( + ctx = gctx.New() + content = `{"a":"b", "c":1}` + adapter, err = gcfg.NewAdapterContent(content) + ) + if err != nil { + panic(err) + } + config := gcfg.NewWithAdapter(adapter) + fmt.Println(config.MustGet(ctx, "a")) + fmt.Println(config.MustGet(ctx, "c")) + + // Output: + // b + // 1 +} diff --git a/os/glog/glog_logger.go b/os/glog/glog_logger.go index 5eb8b3c24..b2484553e 100644 --- a/os/glog/glog_logger.go +++ b/os/glog/glog_logger.go @@ -219,8 +219,8 @@ func (l *Logger) print(ctx context.Context, level int, stack string, values ...a } } -// doDefaultPrint outputs the logging content according configuration. -func (l *Logger) doDefaultPrint(ctx context.Context, input *HandlerInput) *bytes.Buffer { +// doFinalPrint outputs the logging content according configuration. +func (l *Logger) doFinalPrint(ctx context.Context, input *HandlerInput) *bytes.Buffer { var buffer *bytes.Buffer // Allow output to stdout? if l.config.StdoutPrint { diff --git a/os/glog/glog_logger_handler.go b/os/glog/glog_logger_handler.go index 9b632beaa..e2d931592 100644 --- a/os/glog/glog_logger_handler.go +++ b/os/glog/glog_logger_handler.go @@ -49,7 +49,7 @@ var defaultHandler Handler // doFinalPrint is a handler for logging content printing. // This handler outputs logging content to file/stdout/write if any of them configured. func doFinalPrint(ctx context.Context, in *HandlerInput) { - buffer := in.Logger.doDefaultPrint(ctx, in) + buffer := in.Logger.doFinalPrint(ctx, in) if in.Buffer.Len() == 0 { in.Buffer = buffer } diff --git a/os/gsession/gsession.go b/os/gsession/gsession.go index fa0917383..e6ed66e63 100644 --- a/os/gsession/gsession.go +++ b/os/gsession/gsession.go @@ -15,7 +15,7 @@ import ( var ( // ErrorDisabled is used for marking certain interface function not used. - ErrorDisabled = gerror.NewOption(gerror.Option{ + ErrorDisabled = gerror.NewWithOption(gerror.Option{ Text: "this feature is disabled in this storage", Code: gcode.CodeNotSupported, }) diff --git a/util/gvalid/gvalid_error.go b/util/gvalid/gvalid_error.go index cd6593da7..099c89878 100644 --- a/util/gvalid/gvalid_error.go +++ b/util/gvalid/gvalid_error.go @@ -44,7 +44,7 @@ func newValidationError(code gcode.Code, rules []fieldRule, fieldRuleErrorMap ma for field, ruleErrorMap := range fieldRuleErrorMap { for rule, err := range ruleErrorMap { if !gerror.HasStack(err) { - ruleErrorMap[rule] = gerror.NewOption(gerror.Option{ + ruleErrorMap[rule] = gerror.NewWithOption(gerror.Option{ Stack: false, Text: gstr.Trim(err.Error()), Code: code, diff --git a/version.go b/version.go index 2cd4a2f6e..12825ec9c 100644 --- a/version.go +++ b/version.go @@ -2,5 +2,5 @@ package gf const ( // VERSION is the current GoFrame version. - VERSION = "v2.5.7" + VERSION = "v2.6.0-beta" )