Version/v2.6.0 beta (#3183)

This commit is contained in:
John Guo 2023-12-04 19:34:48 +08:00 committed by GitHub
parent 0b6dd6fb13
commit ee2cf92479
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 128 additions and 90 deletions

View File

@ -3,13 +3,13 @@ module github.com/gogf/gf/cmd/gf/v2
go 1.18 go 1.18
require ( require (
github.com/gogf/gf/contrib/drivers/clickhouse/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.5.7 github.com/gogf/gf/contrib/drivers/mssql/v2 v2.6.0-beta
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.7 github.com/gogf/gf/contrib/drivers/mysql/v2 v2.6.0-beta
github.com/gogf/gf/contrib/drivers/oracle/v2 v2.5.7 github.com/gogf/gf/contrib/drivers/oracle/v2 v2.6.0-beta
github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.5.7 github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.6.0-beta
github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.5.7 github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.6.0-beta
github.com/gogf/gf/v2 v2.5.7 github.com/gogf/gf/v2 v2.6.0-beta
github.com/minio/selfupdate v0.6.0 github.com/minio/selfupdate v0.6.0
github.com/olekukonko/tablewriter v0.0.5 github.com/olekukonko/tablewriter v0.0.5
golang.org/x/mod v0.9.0 golang.org/x/mod v0.9.0

View File

@ -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.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 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= 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/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 h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=

View File

@ -82,11 +82,11 @@ func init() {
type ( type (
cRunInput struct { cRunInput struct {
g.Meta `name:"run"` g.Meta `name:"run"`
File string `name:"FILE" arg:"true" brief:"{cRunFileBrief}" v:"required"` File string `name:"FILE" arg:"true" brief:"{cRunFileBrief}" v:"required"`
Path string `name:"path" short:"p" brief:"{cRunPathBrief}" d:"./"` Path string `name:"path" short:"p" brief:"{cRunPathBrief}" d:"./"`
Extra string `name:"extra" short:"e" brief:"{cRunExtraBrief}"` Extra string `name:"extra" short:"e" brief:"{cRunExtraBrief}"`
Args string `name:"args" short:"a" brief:"{cRunArgsBrief}"` Args string `name:"args" short:"a" brief:"{cRunArgsBrief}"`
WatchPaths string `name:"watchPaths" short:"w" brief:"{cRunWatchPathsBrief}"` WatchPaths []string `name:"watchPaths" short:"w" brief:"{cRunWatchPathsBrief}"`
} }
cRunOutput struct{} 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`) 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{ app := &cRunApp{
File: in.File, File: in.File,
Path: in.Path, Path: in.Path,
Options: in.Extra, Options: in.Extra,
Args: in.Args, Args: in.Args,
WatchPaths: strings.Split(in.WatchPaths, ","), WatchPaths: in.WatchPaths,
} }
dirty := gtype.NewBool() dirty := gtype.NewBool()
_, err = gfsnotify.Add(gfile.RealPath("."), func(event *gfsnotify.Event) { _, err = gfsnotify.Add(gfile.RealPath("."), func(event *gfsnotify.Event) {

View File

@ -74,7 +74,7 @@ type (
SdkStdVersion bool `short:"v" name:"sdkStdVersion" brief:"{CGenCtrlBriefSdkStdVersion}" orphan:"true"` SdkStdVersion bool `short:"v" name:"sdkStdVersion" brief:"{CGenCtrlBriefSdkStdVersion}" orphan:"true"`
SdkNoV1 bool `short:"n" name:"sdkNoV1" brief:"{CGenCtrlBriefSdkNoV1}" orphan:"true"` SdkNoV1 bool `short:"n" name:"sdkNoV1" brief:"{CGenCtrlBriefSdkNoV1}" orphan:"true"`
Clear bool `short:"c" name:"clear" brief:"{CGenCtrlBriefClear}" 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{} CGenCtrlOutput struct{}
) )

View File

@ -4,7 +4,7 @@ go 1.18
require ( require (
github.com/apolloconfig/agollo/v4 v4.3.1 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 ( require (

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/consul/v2
go 1.19 go 1.19
require ( 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/consul/api v1.24.0
github.com/hashicorp/go-cleanhttp v0.5.2 github.com/hashicorp/go-cleanhttp v0.5.2
) )

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/kubecm/v2
go 1.19 go 1.19
require ( 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/api v0.27.4
k8s.io/apimachinery v0.27.4 k8s.io/apimachinery v0.27.4
k8s.io/client-go v0.27.4 k8s.io/client-go v0.27.4

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/nacos/v2
go 1.18 go 1.18
require ( 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 github.com/nacos-group/nacos-sdk-go v1.1.4
) )

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/polaris/v2
go 1.18 go 1.18
require ( 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 github.com/polarismesh/polaris-go v1.5.5
) )

View File

@ -4,7 +4,7 @@ go 1.18
require ( require (
github.com/ClickHouse/clickhouse-go/v2 v2.0.15 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/google/uuid v1.3.0
github.com/shopspring/decimal v1.3.1 github.com/shopspring/decimal v1.3.1
) )

View File

@ -6,7 +6,7 @@ replace github.com/gogf/gf/v2 => ../../../
require ( require (
gitee.com/chunanyong/dm v1.8.12 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 ( require (

View File

@ -4,7 +4,7 @@ go 1.18
require ( require (
github.com/denisenkom/go-mssqldb v0.12.3 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 ( require (

View File

@ -4,7 +4,7 @@ go 1.18
require ( require (
github.com/go-sql-driver/mysql v1.7.1 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 ( require (

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/oracle/v2
go 1.18 go 1.18
require ( 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 github.com/sijms/go-ora/v2 v2.7.10
) )

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/pgsql/v2
go 1.18 go 1.18
require ( 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 github.com/lib/pq v1.10.9
) )

View File

@ -4,7 +4,7 @@ go 1.18
require ( require (
github.com/glebarez/go-sqlite v1.21.2 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 ( require (

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/sqlitecgo/v2
go 1.18 go 1.18
require ( 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 github.com/mattn/go-sqlite3 v1.14.17
) )

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/nosql/redis/v2
go 1.18 go 1.18
require ( 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 github.com/redis/go-redis/v9 v9.2.1
go.opentelemetry.io/otel v1.14.0 go.opentelemetry.io/otel v1.14.0
go.opentelemetry.io/otel/trace v1.14.0 go.opentelemetry.io/otel/trace v1.14.0

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/etcd/v2
go 1.18 go 1.18
require ( 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 go.etcd.io/etcd/client/v3 v3.5.7
) )

View File

@ -2,7 +2,7 @@ module github.com/gogf/gf/contrib/registry/file/v2
go 1.18 go 1.18
require github.com/gogf/gf/v2 v2.5.7 require github.com/gogf/gf/v2 v2.6.0-beta
require ( require (
github.com/BurntSushi/toml v1.2.0 // indirect github.com/BurntSushi/toml v1.2.0 // indirect

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/nacos/v2
go 1.18 go 1.18
require ( 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 github.com/joy999/nacos-sdk-go v0.0.0-20231120071639-10a34b3e7288
) )

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/polaris/v2
go 1.18 go 1.18
require ( 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 github.com/polarismesh/polaris-go v1.5.5
) )

View File

@ -4,7 +4,7 @@ go 1.18
require ( require (
github.com/go-zookeeper/zk v1.0.3 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 golang.org/x/sync v0.4.0
) )

View File

@ -3,8 +3,8 @@ module github.com/gogf/gf/contrib/rpc/grpcx/v2
go 1.18 go 1.18
require ( require (
github.com/gogf/gf/contrib/registry/file/v2 v2.5.7 github.com/gogf/gf/contrib/registry/file/v2 v2.6.0-beta
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 v1.14.0
go.opentelemetry.io/otel/trace v1.14.0 go.opentelemetry.io/otel/trace v1.14.0
google.golang.org/grpc v1.57.2 google.golang.org/grpc v1.57.2

View File

@ -8,7 +8,6 @@ package grpcx
import ( import (
"context" "context"
"google.golang.org/grpc" "google.golang.org/grpc"
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
@ -18,18 +17,41 @@ import (
// GrpcServerConfig is the configuration for server. // GrpcServerConfig is the configuration for server.
type GrpcServerConfig struct { type GrpcServerConfig struct {
Address string // (optional) Single address for server listening, use `:0` or `ip:0` to serve random port. // (optional) Name for current service.
Name string // (optional) Name for current service. Name string
Logger *glog.Logger // (optional) Logger for server.
LogPath string // (optional) LogPath specifies the directory for storing logging files. // (optional) Single address for server listening, use `:0` or `ip:0` to serve random port.
LogStdout bool // (optional) LogStdout specifies whether printing logging content to stdout. Address string
ErrorStack bool // (optional) ErrorStack specifies whether logging stack information when error.
ErrorLogEnabled bool // (optional) ErrorLogEnabled enables error logging content to files. // (optional) Logger for server.
ErrorLogPattern string // (optional) ErrorLogPattern specifies the error log file pattern like: error-{Ymd}.log Logger *glog.Logger
AccessLogEnabled bool // (optional) AccessLogEnabled enables access logging content to file.
AccessLogPattern string // (optional) AccessLogPattern specifies the error log file pattern like: access-{Ymd}.log // (optional) LogPath specifies the directory for storing logging files.
Endpoints []string // (optional) Endpoints are custom endpoints for service register, it uses Address if empty. LogPath string
Options []grpc.ServerOption // (optional) GRPC Server options.
// (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. // 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. // Reading configuration file and updating the configured keys.
if g.Cfg().Available(ctx) { if g.Cfg().Available(ctx) {
// Server attributes configuration.
if err = g.Cfg().MustGet(ctx, configNodeNameGrpcServer).Struct(&config); err != nil { if err = g.Cfg().MustGet(ctx, configNodeNameGrpcServer).Struct(&config); err != nil {
g.Log().Error(ctx, err) g.Log().Error(ctx, err)
} }

View File

@ -2,7 +2,7 @@ module github.com/gogf/gf/contrib/sdk/httpclient/v2
go 1.18 go 1.18
require github.com/gogf/gf/v2 v2.5.7 require github.com/gogf/gf/v2 v2.6.0-beta
require ( require (
github.com/BurntSushi/toml v1.2.0 // indirect github.com/BurntSushi/toml v1.2.0 // indirect

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/trace/jaeger/v2
go 1.18 go 1.18
require ( 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 v1.14.0
go.opentelemetry.io/otel/exporters/jaeger v1.14.0 go.opentelemetry.io/otel/exporters/jaeger v1.14.0
go.opentelemetry.io/otel/sdk v1.14.0 go.opentelemetry.io/otel/sdk v1.14.0

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/trace/otlpgrpc/v2
go 1.20 go 1.20
require ( 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 v1.19.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/trace/otlphttp/v2
go 1.20 go 1.20
require ( 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 v1.19.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0

View File

@ -16,9 +16,9 @@ type Option struct {
Code gcode.Code // Error code if necessary. 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. // 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{ err := &Error{
error: option.Error, error: option.Error,
text: option.Text, text: option.Text,
@ -29,3 +29,9 @@ func NewOption(option Option) error {
} }
return err return err
} }
// NewOption creates and returns a custom error with Option.
// Deprecated: use NewWithOption instead.
func NewOption(option Option) error {
return NewWithOption(option)
}

View File

@ -442,7 +442,7 @@ func Test_HashCode(t *testing.T) {
func Test_NewOption(t *testing.T) { func Test_NewOption(t *testing.T) {
gtest.C(t, func(t *gtest.T) { gtest.C(t, func(t *gtest.T) {
t.AssertNE(gerror.NewOption(gerror.Option{ t.AssertNE(gerror.NewWithOption(gerror.Option{
Error: errors.New("NewOptionError"), Error: errors.New("NewOptionError"),
Stack: true, Stack: true,
Text: "Text", Text: "Text",

View File

@ -3,21 +3,21 @@ module github.com/gogf/gf/example
go 1.20 go 1.20
require ( require (
github.com/gogf/gf/contrib/config/apollo/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.5.7 github.com/gogf/gf/contrib/config/consul/v2 v2.6.0-beta
github.com/gogf/gf/contrib/config/kubecm/v2 v2.5.7 github.com/gogf/gf/contrib/config/kubecm/v2 v2.6.0-beta
github.com/gogf/gf/contrib/config/nacos/v2 v2.5.7 github.com/gogf/gf/contrib/config/nacos/v2 v2.6.0-beta
github.com/gogf/gf/contrib/config/polaris/v2 v2.5.7 github.com/gogf/gf/contrib/config/polaris/v2 v2.6.0-beta
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.7 github.com/gogf/gf/contrib/drivers/mysql/v2 v2.6.0-beta
github.com/gogf/gf/contrib/nosql/redis/v2 v2.5.7 github.com/gogf/gf/contrib/nosql/redis/v2 v2.6.0-beta
github.com/gogf/gf/contrib/registry/etcd/v2 v2.5.7 github.com/gogf/gf/contrib/registry/etcd/v2 v2.6.0-beta
github.com/gogf/gf/contrib/registry/file/v2 v2.5.7 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/nacos/v2 v2.5.6
github.com/gogf/gf/contrib/registry/polaris/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.5.7 github.com/gogf/gf/contrib/rpc/grpcx/v2 v2.6.0-beta
github.com/gogf/gf/contrib/trace/otlpgrpc/v2 v2.5.7 github.com/gogf/gf/contrib/trace/otlpgrpc/v2 v2.6.0-beta
github.com/gogf/gf/contrib/trace/otlphttp/v2 v2.5.7 github.com/gogf/gf/contrib/trace/otlphttp/v2 v2.6.0-beta
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/consul/api v1.24.0
github.com/hashicorp/go-cleanhttp v0.5.2 github.com/hashicorp/go-cleanhttp v0.5.2
github.com/nacos-group/nacos-sdk-go v1.1.4 github.com/nacos-group/nacos-sdk-go v1.1.4

View File

@ -205,7 +205,7 @@ var (
) )
var ( var (
ErrNeedJsonBody = gerror.NewOption(gerror.Option{ ErrNeedJsonBody = gerror.NewWithOption(gerror.Option{
Text: "the request body content should be JSON format", Text: "the request body content should be JSON format",
Code: gcode.CodeInvalidRequest, Code: gcode.CodeInvalidRequest,
}) })

View File

@ -11,6 +11,7 @@ import (
"os" "os"
"github.com/gogf/gf/v2/frame/g" "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/gcmd"
"github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/os/genv" "github.com/gogf/gf/v2/os/genv"
@ -64,3 +65,21 @@ func ExampleConfig_GetWithCmd() {
// cmd: // cmd:
// cmd:yes // 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
}

View File

@ -219,8 +219,8 @@ func (l *Logger) print(ctx context.Context, level int, stack string, values ...a
} }
} }
// doDefaultPrint outputs the logging content according configuration. // doFinalPrint outputs the logging content according configuration.
func (l *Logger) doDefaultPrint(ctx context.Context, input *HandlerInput) *bytes.Buffer { func (l *Logger) doFinalPrint(ctx context.Context, input *HandlerInput) *bytes.Buffer {
var buffer *bytes.Buffer var buffer *bytes.Buffer
// Allow output to stdout? // Allow output to stdout?
if l.config.StdoutPrint { if l.config.StdoutPrint {

View File

@ -49,7 +49,7 @@ var defaultHandler Handler
// doFinalPrint is a handler for logging content printing. // doFinalPrint is a handler for logging content printing.
// This handler outputs logging content to file/stdout/write if any of them configured. // This handler outputs logging content to file/stdout/write if any of them configured.
func doFinalPrint(ctx context.Context, in *HandlerInput) { func doFinalPrint(ctx context.Context, in *HandlerInput) {
buffer := in.Logger.doDefaultPrint(ctx, in) buffer := in.Logger.doFinalPrint(ctx, in)
if in.Buffer.Len() == 0 { if in.Buffer.Len() == 0 {
in.Buffer = buffer in.Buffer = buffer
} }

View File

@ -15,7 +15,7 @@ import (
var ( var (
// ErrorDisabled is used for marking certain interface function not used. // 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", Text: "this feature is disabled in this storage",
Code: gcode.CodeNotSupported, Code: gcode.CodeNotSupported,
}) })

View File

@ -44,7 +44,7 @@ func newValidationError(code gcode.Code, rules []fieldRule, fieldRuleErrorMap ma
for field, ruleErrorMap := range fieldRuleErrorMap { for field, ruleErrorMap := range fieldRuleErrorMap {
for rule, err := range ruleErrorMap { for rule, err := range ruleErrorMap {
if !gerror.HasStack(err) { if !gerror.HasStack(err) {
ruleErrorMap[rule] = gerror.NewOption(gerror.Option{ ruleErrorMap[rule] = gerror.NewWithOption(gerror.Option{
Stack: false, Stack: false,
Text: gstr.Trim(err.Error()), Text: gstr.Trim(err.Error()),
Code: code, Code: code,

View File

@ -2,5 +2,5 @@ package gf
const ( const (
// VERSION is the current GoFrame version. // VERSION is the current GoFrame version.
VERSION = "v2.5.7" VERSION = "v2.6.0-beta"
) )