From 72222a59f0a52ab7dde4f627b246a99453bc3024 Mon Sep 17 00:00:00 2001 From: Sourcegraph Date: Thu, 6 Oct 2022 23:53:14 +0000 Subject: [PATCH] Rewrites `interface{}` to `any` using `gofmt` --- auth/jwt.go | 4 +- auth/options.go | 8 +- client/client.go | 2 +- client/client_test.go | 4 +- client/json.go | 6 +- clientv3/compare.go | 6 +- clientv3/logger.go | 32 +-- clientv3/retry_interceptor.go | 14 +- etcdctl/ctlv3/command/printer.go | 4 +- etcdctl/ctlv3/command/printer_json.go | 2 +- etcdctl/ctlv3/command/printer_protobuf.go | 2 +- etcdserver/api/membership/cluster_test.go | 8 +- etcdserver/api/rafthttp/pipeline_test.go | 4 +- etcdserver/api/v2auth/auth.go | 2 +- etcdserver/api/v2auth/auth_requests.go | 6 +- etcdserver/api/v2http/client_test.go | 20 +- etcdserver/api/v2store/store_bench_test.go | 2 +- etcdserver/api/v2store/ttl_key_heap.go | 6 +- etcdserver/api/v3compactor/compactor_test.go | 2 +- .../v3election/v3electionpb/v3election.pb.go | 50 ++-- etcdserver/api/v3lock/v3lockpb/v3lock.pb.go | 26 +- etcdserver/api/v3rpc/codec.go | 4 +- etcdserver/api/v3rpc/interceptor.go | 8 +- etcdserver/api/v3rpc/quota.go | 2 +- etcdserver/api/v3rpc/util.go | 2 +- etcdserver/etcdserverpb/rpc.pb.go | 178 +++++++------- etcdserver/quota.go | 14 +- etcdserver/raft.go | 2 +- etcdserver/server.go | 2 +- etcdserver/server_test.go | 54 ++-- functional/rpcpb/rpc.pb.go | 2 +- integration/v2_http_kv_test.go | 190 +++++++------- lease/lease_queue.go | 4 +- mvcc/kvstore_test.go | 64 ++--- pkg/adt/interval_tree.go | 232 +++++++++--------- pkg/logutil/discard_logger.go | 24 +- pkg/logutil/logger.go | 33 ++- pkg/logutil/zap_grpc.go | 24 +- pkg/logutil/zap_raft.go | 24 +- pkg/mock/mockstore/store_recorder.go | 16 +- pkg/mock/mockwait/wait_recorder.go | 4 +- pkg/testutil/assert.go | 8 +- pkg/testutil/recorder.go | 2 +- pkg/traceutil/trace.go | 2 +- pkg/wait/wait.go | 22 +- proxy/grpcproxy/adapter/chan_stream.go | 12 +- .../adapter/election_client_adapter.go | 4 +- .../grpcproxy/adapter/lease_client_adapter.go | 4 +- .../adapter/maintenance_client_adapter.go | 4 +- .../grpcproxy/adapter/watch_client_adapter.go | 4 +- proxy/grpcproxy/util.go | 2 +- raft/logger.go | 48 ++-- raft/rafttest/interaction_env_logger.go | 28 +-- tests/e2e/util.go | 2 +- tests/e2e/v3_curl_test.go | 2 +- .../cockroachdb/datadriven/datadriven.go | 71 +++--- .../coreos/go-semver/semver/semver.go | 2 +- .../coreos/go-systemd/v22/journal/journal.go | 2 +- vendor/github.com/dgrijalva/jwt-go/ecdsa.go | 4 +- .../dgrijalva/jwt-go/ecdsa_utils.go | 4 +- vendor/github.com/dgrijalva/jwt-go/hmac.go | 4 +- .../github.com/dgrijalva/jwt-go/map_claims.go | 2 +- vendor/github.com/dgrijalva/jwt-go/none.go | 4 +- vendor/github.com/dgrijalva/jwt-go/parser.go | 2 +- vendor/github.com/dgrijalva/jwt-go/rsa.go | 4 +- vendor/github.com/dgrijalva/jwt-go/rsa_pss.go | 5 +- .../github.com/dgrijalva/jwt-go/rsa_utils.go | 6 +- .../dgrijalva/jwt-go/signing_method.go | 6 +- vendor/github.com/dgrijalva/jwt-go/token.go | 18 +- vendor/github.com/dustin/go-humanize/times.go | 2 +- .../gogo/protobuf/proto/deprecated.go | 8 +- .../gogo/protobuf/proto/extensions.go | 32 +-- .../gogo/protobuf/proto/extensions_gogo.go | 8 +- vendor/github.com/gogo/protobuf/proto/lib.go | 38 +-- .../gogo/protobuf/proto/message_set.go | 2 +- .../gogo/protobuf/proto/pointer_reflect.go | 3 +- .../gogo/protobuf/proto/pointer_unsafe.go | 3 +- .../gogo/protobuf/proto/properties.go | 6 +- .../gogo/protobuf/proto/table_marshal.go | 8 +- .../gogo/protobuf/proto/table_unmarshal.go | 14 +- vendor/github.com/gogo/protobuf/proto/text.go | 2 +- .../gogo/protobuf/proto/text_parser.go | 2 +- .../descriptor/descriptor_gostring.gen.go | 2 +- .../github.com/golang/groupcache/lru/lru.go | 16 +- .../golang/protobuf/proto/deprecated.go | 8 +- .../golang/protobuf/proto/extensions.go | 36 +-- .../github.com/golang/protobuf/proto/lib.go | 38 +-- .../golang/protobuf/proto/message_set.go | 2 +- .../golang/protobuf/proto/pointer_reflect.go | 3 +- .../golang/protobuf/proto/pointer_unsafe.go | 3 +- .../golang/protobuf/proto/properties.go | 8 +- .../golang/protobuf/proto/table_marshal.go | 6 +- .../golang/protobuf/proto/table_unmarshal.go | 16 +- .../github.com/golang/protobuf/proto/text.go | 2 +- .../golang/protobuf/proto/text_parser.go | 2 +- .../protoc-gen-go/generator/generator.go | 20 +- .../protobuf/ptypes/struct/struct.pb.go | 6 +- vendor/github.com/google/uuid/sql.go | 2 +- .../gorilla/websocket/compression.go | 2 +- vendor/github.com/gorilla/websocket/json.go | 8 +- .../go-grpc-middleware/chain.go | 18 +- .../grpc-ecosystem/go-grpc-middleware/doc.go | 6 +- .../go-grpc-prometheus/client_metrics.go | 8 +- .../go-grpc-prometheus/server_metrics.go | 12 +- .../grpc-gateway/runtime/fieldmask.go | 6 +- .../grpc-gateway/runtime/handler.go | 2 +- .../runtime/marshal_httpbodyproto.go | 4 +- .../grpc-gateway/runtime/marshal_json.go | 4 +- .../grpc-gateway/runtime/marshal_jsonpb.go | 20 +- .../grpc-gateway/runtime/marshal_proto.go | 8 +- .../grpc-gateway/runtime/marshaler.go | 16 +- vendor/github.com/json-iterator/go/adapter.go | 16 +- vendor/github.com/json-iterator/go/any.go | 14 +- .../github.com/json-iterator/go/any_array.go | 12 +- .../github.com/json-iterator/go/any_bool.go | 4 +- .../github.com/json-iterator/go/any_float.go | 2 +- .../github.com/json-iterator/go/any_int32.go | 2 +- .../github.com/json-iterator/go/any_int64.go | 2 +- .../json-iterator/go/any_invalid.go | 6 +- vendor/github.com/json-iterator/go/any_nil.go | 2 +- .../github.com/json-iterator/go/any_number.go | 2 +- .../github.com/json-iterator/go/any_object.go | 18 +- vendor/github.com/json-iterator/go/any_str.go | 4 +- .../github.com/json-iterator/go/any_uint32.go | 2 +- .../github.com/json-iterator/go/any_uint64.go | 2 +- vendor/github.com/json-iterator/go/config.go | 36 +-- vendor/github.com/json-iterator/go/iter.go | 12 +- vendor/github.com/json-iterator/go/reflect.go | 4 +- .../json-iterator/go/reflect_dynamic.go | 2 +- .../json-iterator/go/reflect_json_number.go | 2 +- vendor/github.com/json-iterator/go/stream.go | 2 +- .../modern-go/concurrent/go_below_19.go | 11 +- .../concurrent/unbounded_executor.go | 6 +- .../github.com/modern-go/reflect2/reflect2.go | 65 ++--- .../modern-go/reflect2/safe_field.go | 4 +- .../github.com/modern-go/reflect2/safe_map.go | 12 +- .../modern-go/reflect2/safe_slice.go | 16 +- .../modern-go/reflect2/safe_type.go | 12 +- .../github.com/modern-go/reflect2/type_map.go | 6 +- .../modern-go/reflect2/unsafe_array.go | 8 +- .../modern-go/reflect2/unsafe_eface.go | 16 +- .../modern-go/reflect2/unsafe_field.go | 4 +- .../modern-go/reflect2/unsafe_iface.go | 8 +- .../modern-go/reflect2/unsafe_link.go | 4 +- .../modern-go/reflect2/unsafe_map.go | 18 +- .../modern-go/reflect2/unsafe_ptr.go | 6 +- .../modern-go/reflect2/unsafe_slice.go | 20 +- .../modern-go/reflect2/unsafe_struct.go | 4 +- .../modern-go/reflect2/unsafe_type.go | 12 +- .../prometheus/expvar_collector.go | 8 +- .../client_golang/prometheus/promhttp/http.go | 4 +- .../prometheus/common/expfmt/text_create.go | 4 +- .../prometheus/common/model/labels.go | 2 +- .../prometheus/common/model/time.go | 4 +- .../prometheus/common/model/value.go | 8 +- vendor/github.com/sirupsen/logrus/entry.go | 66 ++--- vendor/github.com/sirupsen/logrus/exported.go | 56 ++--- vendor/github.com/sirupsen/logrus/logger.go | 82 +++---- vendor/github.com/sirupsen/logrus/logrus.go | 80 +++--- .../sirupsen/logrus/text_formatter.go | 6 +- vendor/github.com/sirupsen/logrus/writer.go | 4 +- vendor/github.com/spf13/cobra/cobra.go | 8 +- vendor/github.com/spf13/cobra/command.go | 6 +- vendor/github.com/spf13/pflag/bool.go | 2 +- vendor/github.com/spf13/pflag/bool_slice.go | 2 +- vendor/github.com/spf13/pflag/bytes.go | 2 +- vendor/github.com/spf13/pflag/count.go | 2 +- vendor/github.com/spf13/pflag/duration.go | 2 +- .../github.com/spf13/pflag/duration_slice.go | 2 +- vendor/github.com/spf13/pflag/flag.go | 23 +- vendor/github.com/spf13/pflag/float32.go | 2 +- vendor/github.com/spf13/pflag/float64.go | 2 +- vendor/github.com/spf13/pflag/int.go | 2 +- vendor/github.com/spf13/pflag/int16.go | 2 +- vendor/github.com/spf13/pflag/int32.go | 2 +- vendor/github.com/spf13/pflag/int64.go | 2 +- vendor/github.com/spf13/pflag/int8.go | 2 +- vendor/github.com/spf13/pflag/int_slice.go | 2 +- vendor/github.com/spf13/pflag/ip.go | 2 +- vendor/github.com/spf13/pflag/ip_slice.go | 2 +- vendor/github.com/spf13/pflag/ipmask.go | 2 +- vendor/github.com/spf13/pflag/ipnet.go | 2 +- vendor/github.com/spf13/pflag/string.go | 2 +- vendor/github.com/spf13/pflag/string_array.go | 2 +- vendor/github.com/spf13/pflag/string_slice.go | 30 ++- vendor/github.com/spf13/pflag/uint.go | 2 +- vendor/github.com/spf13/pflag/uint16.go | 2 +- vendor/github.com/spf13/pflag/uint32.go | 2 +- vendor/github.com/spf13/pflag/uint64.go | 2 +- vendor/github.com/spf13/pflag/uint8.go | 2 +- vendor/github.com/spf13/pflag/uint_slice.go | 2 +- .../wsproxy/websocket_proxy.go | 11 +- vendor/github.com/urfave/cli/app.go | 8 +- vendor/github.com/urfave/cli/command.go | 2 +- vendor/github.com/urfave/cli/context.go | 2 +- vendor/github.com/urfave/cli/errors.go | 4 +- vendor/github.com/urfave/cli/flag.go | 6 +- .../github.com/urfave/cli/flag_generated.go | 6 +- vendor/github.com/urfave/cli/help.go | 12 +- vendor/go.etcd.io/bbolt/db.go | 6 +- vendor/go.uber.org/multierr/error.go | 152 ++++++------ vendor/go.uber.org/multierr/go113.go | 3 +- vendor/go.uber.org/zap/buffer/pool.go | 2 +- vendor/go.uber.org/zap/config.go | 2 +- vendor/go.uber.org/zap/doc.go | 60 ++--- vendor/go.uber.org/zap/error.go | 2 +- vendor/go.uber.org/zap/field.go | 4 +- vendor/go.uber.org/zap/stacktrace.go | 2 +- vendor/go.uber.org/zap/sugar.go | 84 ++++--- .../zap/zapcore/console_encoder.go | 4 +- vendor/go.uber.org/zap/zapcore/encoder.go | 4 +- vendor/go.uber.org/zap/zapcore/entry.go | 2 +- vendor/go.uber.org/zap/zapcore/error.go | 16 +- vendor/go.uber.org/zap/zapcore/field.go | 4 +- .../go.uber.org/zap/zapcore/json_encoder.go | 12 +- vendor/go.uber.org/zap/zapcore/level.go | 2 +- .../go.uber.org/zap/zapcore/memory_encoder.go | 16 +- vendor/golang.org/x/net/context/go17.go | 13 +- vendor/golang.org/x/net/context/pre_go17.go | 19 +- vendor/golang.org/x/net/context/pre_go19.go | 3 +- vendor/golang.org/x/net/http2/databuffer.go | 10 +- vendor/golang.org/x/net/http2/frame.go | 6 +- vendor/golang.org/x/net/http2/gotrack.go | 2 +- .../golang.org/x/net/http2/hpack/huffman.go | 2 +- vendor/golang.org/x/net/http2/http2.go | 18 +- vendor/golang.org/x/net/http2/server.go | 27 +- vendor/golang.org/x/net/http2/transport.go | 8 +- vendor/golang.org/x/net/trace/events.go | 10 +- vendor/golang.org/x/net/trace/trace.go | 18 +- .../x/sys/windows/syscall_windows.go | 4 +- vendor/golang.org/x/time/rate/rate.go | 18 +- .../grpc/attributes/attributes.go | 12 +- vendor/google.golang.org/grpc/balancer.go | 2 +- .../grpc/balancer/balancer.go | 8 +- .../grpc_binarylog_v1/binarylog.pb.go | 16 +- vendor/google.golang.org/grpc/call.go | 6 +- vendor/google.golang.org/grpc/clientconn.go | 12 +- vendor/google.golang.org/grpc/codec.go | 8 +- .../grpc/encoding/encoding.go | 4 +- .../grpc/encoding/proto/proto.go | 8 +- .../google.golang.org/grpc/grpclog/grpclog.go | 30 +-- .../google.golang.org/grpc/grpclog/logger.go | 30 +-- .../grpc/grpclog/loggerv2.go | 48 ++-- .../google.golang.org/grpc/health/client.go | 2 +- .../grpc/health/grpc_health_v1/health.pb.go | 6 +- vendor/google.golang.org/grpc/interceptor.go | 12 +- .../grpc/internal/balancerload/load.go | 4 +- .../grpc/internal/binarylog/method_logger.go | 4 +- .../grpc/internal/buffer/unbounded.go | 10 +- .../grpc/internal/channelz/util_linux.go | 3 +- .../grpc/internal/channelz/util_nonlinux.go | 3 +- .../grpc/internal/internal.go | 12 +- .../grpc/internal/transport/controlbuf.go | 16 +- .../grpc/internal/transport/http2_client.go | 14 +- .../grpc/internal/transport/http2_server.go | 4 +- .../grpc/internal/transport/log.go | 6 +- .../grpc/internal/transport/transport.go | 6 +- .../google.golang.org/grpc/naming/naming.go | 2 +- vendor/google.golang.org/grpc/preloader.go | 2 +- .../grpc/resolver/resolver.go | 2 +- vendor/google.golang.org/grpc/rpc_util.go | 19 +- vendor/google.golang.org/grpc/server.go | 54 ++-- vendor/google.golang.org/grpc/stats/stats.go | 4 +- .../google.golang.org/grpc/status/status.go | 8 +- vendor/google.golang.org/grpc/stream.go | 50 ++-- vendor/google.golang.org/grpc/trace.go | 6 +- vendor/gopkg.in/yaml.v2/decode.go | 10 +- vendor/gopkg.in/yaml.v2/resolve.go | 8 +- vendor/gopkg.in/yaml.v2/scannerc.go | 40 +-- vendor/gopkg.in/yaml.v2/yaml.go | 75 +++--- vendor/sigs.k8s.io/yaml/yaml.go | 43 ++-- 271 files changed, 1930 insertions(+), 1869 deletions(-) diff --git a/auth/jwt.go b/auth/jwt.go index 778bb9a2d..2745afe85 100644 --- a/auth/jwt.go +++ b/auth/jwt.go @@ -28,7 +28,7 @@ import ( type tokenJWT struct { lg *zap.Logger signMethod jwt.SigningMethod - key interface{} + key any ttl time.Duration verifyOnly bool } @@ -45,7 +45,7 @@ func (t *tokenJWT) info(ctx context.Context, token string, rev uint64) (*AuthInf revision uint64 ) - parsed, err := jwt.Parse(token, func(token *jwt.Token) (interface{}, error) { + parsed, err := jwt.Parse(token, func(token *jwt.Token) (any, error) { if token.Method.Alg() != t.signMethod.Alg() { return nil, errors.New("invalid signing method") } diff --git a/auth/options.go b/auth/options.go index f40b92de6..6ff069238 100644 --- a/auth/options.go +++ b/auth/options.go @@ -94,7 +94,7 @@ func (opts *jwtOptions) Parse(optMap map[string]string) error { } // Key will parse and return the appropriately typed key for the selected signature method -func (opts *jwtOptions) Key() (interface{}, error) { +func (opts *jwtOptions) Key() (any, error) { switch opts.SignMethod.(type) { case *jwt.SigningMethodRSA, *jwt.SigningMethodRSAPSS: return opts.rsaKey() @@ -107,14 +107,14 @@ func (opts *jwtOptions) Key() (interface{}, error) { } } -func (opts *jwtOptions) hmacKey() (interface{}, error) { +func (opts *jwtOptions) hmacKey() (any, error) { if len(opts.PrivateKey) == 0 { return nil, ErrMissingKey } return opts.PrivateKey, nil } -func (opts *jwtOptions) rsaKey() (interface{}, error) { +func (opts *jwtOptions) rsaKey() (any, error) { var ( priv *rsa.PrivateKey pub *rsa.PublicKey @@ -152,7 +152,7 @@ func (opts *jwtOptions) rsaKey() (interface{}, error) { return priv, nil } -func (opts *jwtOptions) ecKey() (interface{}, error) { +func (opts *jwtOptions) ecKey() (any, error) { var ( priv *ecdsa.PrivateKey pub *ecdsa.PublicKey diff --git a/client/client.go b/client/client.go index 197b90247..bc7b14b76 100644 --- a/client/client.go +++ b/client/client.go @@ -41,7 +41,7 @@ var ( // oneShotCtxValue is set on a context using WithValue(&oneShotValue) so // that Do() will not retry a request - oneShotCtxValue interface{} + oneShotCtxValue any ) var DefaultRequestTimeout = 5 * time.Second diff --git a/client/client_test.go b/client/client_test.go index 8691db2df..4aa5b667d 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -480,8 +480,8 @@ func (f fakeCancelContext) Done() <-chan struct{} { d <- struct{}{} return d } -func (f fakeCancelContext) Err() error { return errFakeCancelContext } -func (f fakeCancelContext) Value(key interface{}) interface{} { return 1 } +func (f fakeCancelContext) Err() error { return errFakeCancelContext } +func (f fakeCancelContext) Value(key any) any { return 1 } func withTimeout(parent context.Context, timeout time.Duration) ( ctx context.Context, diff --git a/client/json.go b/client/json.go index 97cdbcd7c..ee2ce5c0d 100644 --- a/client/json.go +++ b/client/json.go @@ -42,17 +42,17 @@ func (customNumberDecoder) Decode(ptr unsafe.Pointer, iter *jsoniter.Iterator) { iter.ReadVal(&number) i64, err := strconv.ParseInt(string(number), 10, 64) if err == nil { - *(*interface{})(ptr) = i64 + *(*any)(ptr) = i64 return } f64, err := strconv.ParseFloat(string(number), 64) if err == nil { - *(*interface{})(ptr) = f64 + *(*any)(ptr) = f64 return } iter.ReportError("DecodeNumber", err.Error()) default: - *(*interface{})(ptr) = iter.Read() + *(*any)(ptr) = iter.Read() } } diff --git a/clientv3/compare.go b/clientv3/compare.go index 149ab7893..6f946a1a5 100644 --- a/clientv3/compare.go +++ b/clientv3/compare.go @@ -30,7 +30,7 @@ const ( type Cmp pb.Compare -func Compare(cmp Cmp, result string, v interface{}) Cmp { +func Compare(cmp Cmp, result string, v any) Cmp { var r pb.Compare_CompareResult switch result { @@ -120,7 +120,7 @@ func (cmp Cmp) WithPrefix() Cmp { } // mustInt64 panics if val isn't an int or int64. It returns an int64 otherwise. -func mustInt64(val interface{}) int64 { +func mustInt64(val any) int64 { if v, ok := val.(int64); ok { return v } @@ -132,7 +132,7 @@ func mustInt64(val interface{}) int64 { // mustInt64orLeaseID panics if val isn't a LeaseID, int or int64. It returns an // int64 otherwise. -func mustInt64orLeaseID(val interface{}) int64 { +func mustInt64orLeaseID(val any) int64 { if v, ok := val.(LeaseID); ok { return int64(v) } diff --git a/clientv3/logger.go b/clientv3/logger.go index 0e0bfc8aa..f33cc0c8d 100644 --- a/clientv3/logger.go +++ b/clientv3/logger.go @@ -70,26 +70,26 @@ func (s *settableLogger) get() grpclog.LoggerV2 { // implement the grpclog.LoggerV2 interface -func (s *settableLogger) Info(args ...interface{}) { s.get().Info(args...) } -func (s *settableLogger) Infof(format string, args ...interface{}) { s.get().Infof(format, args...) } -func (s *settableLogger) Infoln(args ...interface{}) { s.get().Infoln(args...) } -func (s *settableLogger) Warning(args ...interface{}) { s.get().Warning(args...) } -func (s *settableLogger) Warningf(format string, args ...interface{}) { +func (s *settableLogger) Info(args ...any) { s.get().Info(args...) } +func (s *settableLogger) Infof(format string, args ...any) { s.get().Infof(format, args...) } +func (s *settableLogger) Infoln(args ...any) { s.get().Infoln(args...) } +func (s *settableLogger) Warning(args ...any) { s.get().Warning(args...) } +func (s *settableLogger) Warningf(format string, args ...any) { s.get().Warningf(format, args...) } -func (s *settableLogger) Warningln(args ...interface{}) { s.get().Warningln(args...) } -func (s *settableLogger) Error(args ...interface{}) { s.get().Error(args...) } -func (s *settableLogger) Errorf(format string, args ...interface{}) { +func (s *settableLogger) Warningln(args ...any) { s.get().Warningln(args...) } +func (s *settableLogger) Error(args ...any) { s.get().Error(args...) } +func (s *settableLogger) Errorf(format string, args ...any) { s.get().Errorf(format, args...) } -func (s *settableLogger) Errorln(args ...interface{}) { s.get().Errorln(args...) } -func (s *settableLogger) Fatal(args ...interface{}) { s.get().Fatal(args...) } -func (s *settableLogger) Fatalf(format string, args ...interface{}) { s.get().Fatalf(format, args...) } -func (s *settableLogger) Fatalln(args ...interface{}) { s.get().Fatalln(args...) } -func (s *settableLogger) Print(args ...interface{}) { s.get().Info(args...) } -func (s *settableLogger) Printf(format string, args ...interface{}) { s.get().Infof(format, args...) } -func (s *settableLogger) Println(args ...interface{}) { s.get().Infoln(args...) } -func (s *settableLogger) V(l int) bool { return s.get().V(l) } +func (s *settableLogger) Errorln(args ...any) { s.get().Errorln(args...) } +func (s *settableLogger) Fatal(args ...any) { s.get().Fatal(args...) } +func (s *settableLogger) Fatalf(format string, args ...any) { s.get().Fatalf(format, args...) } +func (s *settableLogger) Fatalln(args ...any) { s.get().Fatalln(args...) } +func (s *settableLogger) Print(args ...any) { s.get().Info(args...) } +func (s *settableLogger) Printf(format string, args ...any) { s.get().Infof(format, args...) } +func (s *settableLogger) Println(args ...any) { s.get().Infoln(args...) } +func (s *settableLogger) V(l int) bool { return s.get().V(l) } func (s *settableLogger) Lvl(lvl int) grpclog.LoggerV2 { s.mu.RLock() l := s.l diff --git a/clientv3/retry_interceptor.go b/clientv3/retry_interceptor.go index c0fda8439..dc0c9c5ce 100644 --- a/clientv3/retry_interceptor.go +++ b/clientv3/retry_interceptor.go @@ -37,7 +37,7 @@ import ( // changed through options (e.g. WithMax) on creation of the interceptor or on call (through grpc.CallOptions). func (c *Client) unaryClientInterceptor(logger *zap.Logger, optFuncs ...retryOption) grpc.UnaryClientInterceptor { intOpts := reuseOrNewWithCallOptions(defaultOptions, optFuncs) - return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { + return func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { ctx = withVersion(ctx) grpcOpts, retryOpts := filterCallOptions(opts) callOpts := reuseOrNewWithCallOptions(intOpts, retryOpts) @@ -138,9 +138,9 @@ func (c *Client) streamClientInterceptor(logger *zap.Logger, optFuncs ...retryOp type serverStreamingRetryingStream struct { grpc.ClientStream client *Client - bufferedSends []interface{} // single message that the client can sen - receivedGood bool // indicates whether any prior receives were successful - wasClosedSend bool // indicates that CloseSend was closed + bufferedSends []any // single message that the client can sen + receivedGood bool // indicates whether any prior receives were successful + wasClosedSend bool // indicates that CloseSend was closed ctx context.Context callOpts *options streamerCall func(ctx context.Context) (grpc.ClientStream, error) @@ -159,7 +159,7 @@ func (s *serverStreamingRetryingStream) getStream() grpc.ClientStream { return s.ClientStream } -func (s *serverStreamingRetryingStream) SendMsg(m interface{}) error { +func (s *serverStreamingRetryingStream) SendMsg(m any) error { s.mu.Lock() s.bufferedSends = append(s.bufferedSends, m) s.mu.Unlock() @@ -181,7 +181,7 @@ func (s *serverStreamingRetryingStream) Trailer() metadata.MD { return s.getStream().Trailer() } -func (s *serverStreamingRetryingStream) RecvMsg(m interface{}) error { +func (s *serverStreamingRetryingStream) RecvMsg(m any) error { attemptRetry, lastErr := s.receiveMsgAndIndicateRetry(m) if !attemptRetry { return lastErr // success or hard failure @@ -208,7 +208,7 @@ func (s *serverStreamingRetryingStream) RecvMsg(m interface{}) error { return lastErr } -func (s *serverStreamingRetryingStream) receiveMsgAndIndicateRetry(m interface{}) (bool, error) { +func (s *serverStreamingRetryingStream) receiveMsgAndIndicateRetry(m any) (bool, error) { s.mu.RLock() wasGood := s.receivedGood s.mu.RUnlock() diff --git a/etcdctl/ctlv3/command/printer.go b/etcdctl/ctlv3/command/printer.go index 686c49975..e21dc6dee 100644 --- a/etcdctl/ctlv3/command/printer.go +++ b/etcdctl/ctlv3/command/printer.go @@ -89,7 +89,7 @@ func NewPrinter(printerType string, isHex bool) printer { type printerRPC struct { printer - p func(interface{}) + p func(any) } func (p *printerRPC) Del(r v3.DeleteResponse) { p.p((*pb.DeleteRangeResponse)(&r)) } @@ -150,7 +150,7 @@ func (p *printerRPC) AuthStatus(r v3.AuthStatusResponse) { type printerUnsupported struct{ printerRPC } func newPrinterUnsupported(n string) printer { - f := func(interface{}) { + f := func(any) { ExitWithError(ExitBadFeature, errors.New(n+" not supported as output format")) } return &printerUnsupported{printerRPC{nil, f}} diff --git a/etcdctl/ctlv3/command/printer_json.go b/etcdctl/ctlv3/command/printer_json.go index 2a6ea9f21..72aff92f6 100644 --- a/etcdctl/ctlv3/command/printer_json.go +++ b/etcdctl/ctlv3/command/printer_json.go @@ -35,7 +35,7 @@ func (p *jsonPrinter) EndpointStatus(r []epStatus) { printJSON(r) } func (p *jsonPrinter) EndpointHashKV(r []epHashKV) { printJSON(r) } func (p *jsonPrinter) DBStatus(r snapshot.Status) { printJSON(r) } -func printJSON(v interface{}) { +func printJSON(v any) { b, err := json.Marshal(v) if err != nil { fmt.Fprintf(os.Stderr, "%v\n", err) diff --git a/etcdctl/ctlv3/command/printer_protobuf.go b/etcdctl/ctlv3/command/printer_protobuf.go index 9c2446c84..59cb5fa36 100644 --- a/etcdctl/ctlv3/command/printer_protobuf.go +++ b/etcdctl/ctlv3/command/printer_protobuf.go @@ -50,7 +50,7 @@ func (p *pbPrinter) Watch(r v3.WatchResponse) { printPB(&wr) } -func printPB(v interface{}) { +func printPB(v any) { m, ok := v.(pbMarshal) if !ok { ExitWithError(ExitBadFeature, fmt.Errorf("marshal unsupported for type %T (%v)", v, v)) diff --git a/etcdserver/api/membership/cluster_test.go b/etcdserver/api/membership/cluster_test.go index 2a1e8b8d4..f16bc1274 100644 --- a/etcdserver/api/membership/cluster_test.go +++ b/etcdserver/api/membership/cluster_test.go @@ -491,7 +491,7 @@ func TestClusterAddMember(t *testing.T) { wactions := []testutil.Action{ { Name: "Create", - Params: []interface{}{ + Params: []any{ path.Join(StoreMembersPrefix, "1", "raftAttributes"), false, `{"peerURLs":null}`, @@ -514,7 +514,7 @@ func TestClusterAddMemberAsLearner(t *testing.T) { wactions := []testutil.Action{ { Name: "Create", - Params: []interface{}{ + Params: []any{ path.Join(StoreMembersPrefix, "1", "raftAttributes"), false, `{"peerURLs":null,"isLearner":true}`, @@ -555,8 +555,8 @@ func TestClusterRemoveMember(t *testing.T) { c.RemoveMember(1) wactions := []testutil.Action{ - {Name: "Delete", Params: []interface{}{MemberStoreKey(1), true, true}}, - {Name: "Create", Params: []interface{}{RemovedMemberStoreKey(1), false, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}}}, + {Name: "Delete", Params: []any{MemberStoreKey(1), true, true}}, + {Name: "Create", Params: []any{RemovedMemberStoreKey(1), false, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}}}, } if !reflect.DeepEqual(st.Action(), wactions) { t.Errorf("actions = %v, want %v", st.Action(), wactions) diff --git a/etcdserver/api/rafthttp/pipeline_test.go b/etcdserver/api/rafthttp/pipeline_test.go index 0f8388ce8..9025cf85a 100644 --- a/etcdserver/api/rafthttp/pipeline_test.go +++ b/etcdserver/api/rafthttp/pipeline_test.go @@ -277,7 +277,7 @@ func (t *respRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) t.mu.Lock() defer t.mu.Unlock() if t.rec != nil { - t.rec.Record(testutil.Action{Name: "req", Params: []interface{}{req}}) + t.rec.Record(testutil.Action{Name: "req", Params: []any{req}}) } return &http.Response{StatusCode: t.code, Header: t.header, Body: &nopReadCloser{}}, t.err } @@ -288,7 +288,7 @@ type roundTripperRecorder struct { func (t *roundTripperRecorder) RoundTrip(req *http.Request) (*http.Response, error) { if t.rec != nil { - t.rec.Record(testutil.Action{Name: "req", Params: []interface{}{req}}) + t.rec.Record(testutil.Action{Name: "req", Params: []any{req}}) } return &http.Response{StatusCode: http.StatusNoContent, Body: &nopReadCloser{}}, nil } diff --git a/etcdserver/api/v2auth/auth.go b/etcdserver/api/v2auth/auth.go index dfefc3545..136477132 100644 --- a/etcdserver/api/v2auth/auth.go +++ b/etcdserver/api/v2auth/auth.go @@ -138,7 +138,7 @@ type Error struct { func (ae Error) Error() string { return ae.Errmsg } func (ae Error) HTTPStatus() int { return ae.Status } -func authErr(hs int, s string, v ...interface{}) Error { +func authErr(hs int, s string, v ...any) Error { return Error{Status: hs, Errmsg: fmt.Sprintf("auth: "+s, v...)} } diff --git a/etcdserver/api/v2auth/auth_requests.go b/etcdserver/api/v2auth/auth_requests.go index a6cbfe7e5..30f2a744d 100644 --- a/etcdserver/api/v2auth/auth_requests.go +++ b/etcdserver/api/v2auth/auth_requests.go @@ -132,13 +132,13 @@ func (s *store) requestResource(res string, quorum bool) (etcdserver.Response, e return s.server.Do(ctx, rr) } -func (s *store) updateResource(res string, value interface{}) (etcdserver.Response, error) { +func (s *store) updateResource(res string, value any) (etcdserver.Response, error) { return s.setResource(res, value, true) } -func (s *store) createResource(res string, value interface{}) (etcdserver.Response, error) { +func (s *store) createResource(res string, value any) (etcdserver.Response, error) { return s.setResource(res, value, false) } -func (s *store) setResource(res string, value interface{}, prevexist bool) (etcdserver.Response, error) { +func (s *store) setResource(res string, value any, prevexist bool) (etcdserver.Response, error) { err := s.ensureAuthDirectories() if err != nil { return etcdserver.Response{}, err diff --git a/etcdserver/api/v2http/client_test.go b/etcdserver/api/v2http/client_test.go index fbf1fae38..1b4406d7c 100644 --- a/etcdserver/api/v2http/client_test.go +++ b/etcdserver/api/v2http/client_test.go @@ -111,35 +111,35 @@ type serverRecorder struct { } func (s *serverRecorder) Do(_ context.Context, r etcdserverpb.Request) (etcdserver.Response, error) { - s.actions = append(s.actions, action{name: "Do", params: []interface{}{r}}) + s.actions = append(s.actions, action{name: "Do", params: []any{r}}) return etcdserver.Response{}, nil } func (s *serverRecorder) Process(_ context.Context, m raftpb.Message) error { - s.actions = append(s.actions, action{name: "Process", params: []interface{}{m}}) + s.actions = append(s.actions, action{name: "Process", params: []any{m}}) return nil } func (s *serverRecorder) AddMember(_ context.Context, m membership.Member) ([]*membership.Member, error) { - s.actions = append(s.actions, action{name: "AddMember", params: []interface{}{m}}) + s.actions = append(s.actions, action{name: "AddMember", params: []any{m}}) return nil, nil } func (s *serverRecorder) RemoveMember(_ context.Context, id uint64) ([]*membership.Member, error) { - s.actions = append(s.actions, action{name: "RemoveMember", params: []interface{}{id}}) + s.actions = append(s.actions, action{name: "RemoveMember", params: []any{id}}) return nil, nil } func (s *serverRecorder) UpdateMember(_ context.Context, m membership.Member) ([]*membership.Member, error) { - s.actions = append(s.actions, action{name: "UpdateMember", params: []interface{}{m}}) + s.actions = append(s.actions, action{name: "UpdateMember", params: []any{m}}) return nil, nil } func (s *serverRecorder) PromoteMember(_ context.Context, id uint64) ([]*membership.Member, error) { - s.actions = append(s.actions, action{name: "PromoteMember", params: []interface{}{id}}) + s.actions = append(s.actions, action{name: "PromoteMember", params: []any{id}}) return nil, nil } type action struct { name string - params []interface{} + params []any } // flushingRecorder provides a channel to allow users to block until the Recorder is Flushed() @@ -810,7 +810,7 @@ func TestServeMembersCreate(t *testing.T) { }, } - wactions := []action{{name: "AddMember", params: []interface{}{wm}}} + wactions := []action{{name: "AddMember", params: []any{wm}}} if !reflect.DeepEqual(s.actions, wactions) { t.Errorf("actions = %+v, want %+v", s.actions, wactions) } @@ -844,7 +844,7 @@ func TestServeMembersDelete(t *testing.T) { if g != "" { t.Errorf("got body=%q, want %q", g, "") } - wactions := []action{{name: "RemoveMember", params: []interface{}{uint64(0xBEEF)}}} + wactions := []action{{name: "RemoveMember", params: []any{uint64(0xBEEF)}}} if !reflect.DeepEqual(s.actions, wactions) { t.Errorf("actions = %+v, want %+v", s.actions, wactions) } @@ -887,7 +887,7 @@ func TestServeMembersUpdate(t *testing.T) { }, } - wactions := []action{{name: "UpdateMember", params: []interface{}{wm}}} + wactions := []action{{name: "UpdateMember", params: []any{wm}}} if !reflect.DeepEqual(s.actions, wactions) { t.Errorf("actions = %+v, want %+v", s.actions, wactions) } diff --git a/etcdserver/api/v2store/store_bench_test.go b/etcdserver/api/v2store/store_bench_test.go index f8f939aff..561ea6ab5 100644 --- a/etcdserver/api/v2store/store_bench_test.go +++ b/etcdserver/api/v2store/store_bench_test.go @@ -174,7 +174,7 @@ func BenchmarkWatchOneKey(b *testing.B) { } } -func benchStoreSet(b *testing.B, valueSize int, process func(interface{}) ([]byte, error)) { +func benchStoreSet(b *testing.B, valueSize int, process func(any) ([]byte, error)) { s := newStore() b.StopTimer() kvs, size := generateNRandomKV(b.N, valueSize) diff --git a/etcdserver/api/v2store/ttl_key_heap.go b/etcdserver/api/v2store/ttl_key_heap.go index 477d2b9f3..2d588da9d 100644 --- a/etcdserver/api/v2store/ttl_key_heap.go +++ b/etcdserver/api/v2store/ttl_key_heap.go @@ -45,13 +45,13 @@ func (h ttlKeyHeap) Swap(i, j int) { h.keyMap[h.array[j]] = j } -func (h *ttlKeyHeap) Push(x interface{}) { +func (h *ttlKeyHeap) Push(x any) { n, _ := x.(*node) h.keyMap[n] = len(h.array) h.array = append(h.array, n) } -func (h *ttlKeyHeap) Pop() interface{} { +func (h *ttlKeyHeap) Pop() any { old := h.array n := len(old) x := old[n-1] @@ -77,7 +77,7 @@ func (h *ttlKeyHeap) pop() *node { return n } -func (h *ttlKeyHeap) push(x interface{}) { +func (h *ttlKeyHeap) push(x any) { heap.Push(h, x) } diff --git a/etcdserver/api/v3compactor/compactor_test.go b/etcdserver/api/v3compactor/compactor_test.go index c10a39858..bc582adf0 100644 --- a/etcdserver/api/v3compactor/compactor_test.go +++ b/etcdserver/api/v3compactor/compactor_test.go @@ -27,7 +27,7 @@ type fakeCompactable struct { } func (fc *fakeCompactable) Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error) { - fc.Record(testutil.Action{Name: "c", Params: []interface{}{r}}) + fc.Record(testutil.Action{Name: "c", Params: []any{r}}) return &pb.CompactionResponse{}, nil } diff --git a/etcdserver/api/v3election/v3electionpb/v3election.pb.go b/etcdserver/api/v3election/v3electionpb/v3election.pb.go index 05e62fc50..12c893f22 100644 --- a/etcdserver/api/v3election/v3electionpb/v3election.pb.go +++ b/etcdserver/api/v3election/v3electionpb/v3election.pb.go @@ -2,21 +2,23 @@ // source: v3election.proto /* - Package v3electionpb is a generated protocol buffer package. - - It is generated from these files: - v3election.proto - - It has these top-level messages: - CampaignRequest - CampaignResponse - LeaderKey - LeaderRequest - LeaderResponse - ResignRequest - ResignResponse - ProclaimRequest - ProclaimResponse +Package v3electionpb is a generated protocol buffer package. + +It is generated from these files: + + v3election.proto + +It has these top-level messages: + + CampaignRequest + CampaignResponse + LeaderKey + LeaderRequest + LeaderResponse + ResignRequest + ResignResponse + ProclaimRequest + ProclaimResponse */ package v3electionpb @@ -418,7 +420,7 @@ func RegisterElectionServer(s *grpc.Server, srv ElectionServer) { s.RegisterService(&_Election_serviceDesc, srv) } -func _Election_Campaign_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Election_Campaign_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(CampaignRequest) if err := dec(in); err != nil { return nil, err @@ -430,13 +432,13 @@ func _Election_Campaign_Handler(srv interface{}, ctx context.Context, dec func(i Server: srv, FullMethod: "/v3electionpb.Election/Campaign", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ElectionServer).Campaign(ctx, req.(*CampaignRequest)) } return interceptor(ctx, in, info, handler) } -func _Election_Proclaim_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Election_Proclaim_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(ProclaimRequest) if err := dec(in); err != nil { return nil, err @@ -448,13 +450,13 @@ func _Election_Proclaim_Handler(srv interface{}, ctx context.Context, dec func(i Server: srv, FullMethod: "/v3electionpb.Election/Proclaim", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ElectionServer).Proclaim(ctx, req.(*ProclaimRequest)) } return interceptor(ctx, in, info, handler) } -func _Election_Leader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Election_Leader_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(LeaderRequest) if err := dec(in); err != nil { return nil, err @@ -466,13 +468,13 @@ func _Election_Leader_Handler(srv interface{}, ctx context.Context, dec func(int Server: srv, FullMethod: "/v3electionpb.Election/Leader", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ElectionServer).Leader(ctx, req.(*LeaderRequest)) } return interceptor(ctx, in, info, handler) } -func _Election_Observe_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Election_Observe_Handler(srv any, stream grpc.ServerStream) error { m := new(LeaderRequest) if err := stream.RecvMsg(m); err != nil { return err @@ -493,7 +495,7 @@ func (x *electionObserveServer) Send(m *LeaderResponse) error { return x.ServerStream.SendMsg(m) } -func _Election_Resign_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Election_Resign_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(ResignRequest) if err := dec(in); err != nil { return nil, err @@ -505,7 +507,7 @@ func _Election_Resign_Handler(srv interface{}, ctx context.Context, dec func(int Server: srv, FullMethod: "/v3electionpb.Election/Resign", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ElectionServer).Resign(ctx, req.(*ResignRequest)) } return interceptor(ctx, in, info, handler) diff --git a/etcdserver/api/v3lock/v3lockpb/v3lock.pb.go b/etcdserver/api/v3lock/v3lockpb/v3lock.pb.go index ad139c1c8..388e883e5 100644 --- a/etcdserver/api/v3lock/v3lockpb/v3lock.pb.go +++ b/etcdserver/api/v3lock/v3lockpb/v3lock.pb.go @@ -2,16 +2,18 @@ // source: v3lock.proto /* - Package v3lockpb is a generated protocol buffer package. +Package v3lockpb is a generated protocol buffer package. - It is generated from these files: - v3lock.proto +It is generated from these files: - It has these top-level messages: - LockRequest - LockResponse - UnlockRequest - UnlockResponse + v3lock.proto + +It has these top-level messages: + + LockRequest + LockResponse + UnlockRequest + UnlockResponse */ package v3lockpb @@ -211,7 +213,7 @@ func RegisterLockServer(s *grpc.Server, srv LockServer) { s.RegisterService(&_Lock_serviceDesc, srv) } -func _Lock_Lock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Lock_Lock_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(LockRequest) if err := dec(in); err != nil { return nil, err @@ -223,13 +225,13 @@ func _Lock_Lock_Handler(srv interface{}, ctx context.Context, dec func(interface Server: srv, FullMethod: "/v3lockpb.Lock/Lock", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(LockServer).Lock(ctx, req.(*LockRequest)) } return interceptor(ctx, in, info, handler) } -func _Lock_Unlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Lock_Unlock_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(UnlockRequest) if err := dec(in); err != nil { return nil, err @@ -241,7 +243,7 @@ func _Lock_Unlock_Handler(srv interface{}, ctx context.Context, dec func(interfa Server: srv, FullMethod: "/v3lockpb.Lock/Unlock", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(LockServer).Unlock(ctx, req.(*UnlockRequest)) } return interceptor(ctx, in, info, handler) diff --git a/etcdserver/api/v3rpc/codec.go b/etcdserver/api/v3rpc/codec.go index 17a2c87ae..1fe21341b 100644 --- a/etcdserver/api/v3rpc/codec.go +++ b/etcdserver/api/v3rpc/codec.go @@ -18,13 +18,13 @@ import "github.com/gogo/protobuf/proto" type codec struct{} -func (c *codec) Marshal(v interface{}) ([]byte, error) { +func (c *codec) Marshal(v any) ([]byte, error) { b, err := proto.Marshal(v.(proto.Message)) sentBytes.Add(float64(len(b))) return b, err } -func (c *codec) Unmarshal(data []byte, v interface{}) error { +func (c *codec) Unmarshal(data []byte, v any) error { receivedBytes.Add(float64(len(data))) return proto.Unmarshal(data, v.(proto.Message)) } diff --git a/etcdserver/api/v3rpc/interceptor.go b/etcdserver/api/v3rpc/interceptor.go index 5bae935df..4a91476c6 100644 --- a/etcdserver/api/v3rpc/interceptor.go +++ b/etcdserver/api/v3rpc/interceptor.go @@ -42,7 +42,7 @@ type streamsMap struct { } func newUnaryInterceptor(s *etcdserver.EtcdServer) grpc.UnaryServerInterceptor { - return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { if !api.IsCapabilityEnabled(api.V3rpcCapability) { return nil, rpctypes.ErrGRPCNotCapable } @@ -71,7 +71,7 @@ func newUnaryInterceptor(s *etcdserver.EtcdServer) grpc.UnaryServerInterceptor { } func newLogUnaryInterceptor(s *etcdserver.EtcdServer) grpc.UnaryServerInterceptor { - return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { startTime := time.Now() resp, err := handler(ctx, req) lg := s.Logger() @@ -82,7 +82,7 @@ func newLogUnaryInterceptor(s *etcdserver.EtcdServer) grpc.UnaryServerIntercepto } } -func logUnaryRequestStats(ctx context.Context, lg *zap.Logger, info *grpc.UnaryServerInfo, startTime time.Time, req interface{}, resp interface{}) { +func logUnaryRequestStats(ctx context.Context, lg *zap.Logger, info *grpc.UnaryServerInfo, startTime time.Time, req any, resp any) { duration := time.Since(startTime) remote := "No remote client info." peerInfo, ok := peer.FromContext(ctx) @@ -179,7 +179,7 @@ func logGenericRequestStats(lg *zap.Logger, startTime time.Time, duration time.D func newStreamInterceptor(s *etcdserver.EtcdServer) grpc.StreamServerInterceptor { smap := monitorLeader(s) - return func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { + return func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { if !api.IsCapabilityEnabled(api.V3rpcCapability) { return rpctypes.ErrGRPCNotCapable } diff --git a/etcdserver/api/v3rpc/quota.go b/etcdserver/api/v3rpc/quota.go index b40edbdfc..ebb51c7cc 100644 --- a/etcdserver/api/v3rpc/quota.go +++ b/etcdserver/api/v3rpc/quota.go @@ -36,7 +36,7 @@ type quotaAlarmer struct { // check whether request satisfies the quota. If there is not enough space, // ignore request and raise the free space alarm. -func (qa *quotaAlarmer) check(ctx context.Context, r interface{}) error { +func (qa *quotaAlarmer) check(ctx context.Context, r any) error { if qa.q.Available(r) { return nil } diff --git a/etcdserver/api/v3rpc/util.go b/etcdserver/api/v3rpc/util.go index 6027724b2..9c4b83ddf 100644 --- a/etcdserver/api/v3rpc/util.go +++ b/etcdserver/api/v3rpc/util.go @@ -124,7 +124,7 @@ func isClientCtxErr(ctxErr error, err error) bool { } // in v3.4, learner is allowed to serve serializable read and endpoint status -func isRPCSupportedForLearner(req interface{}) bool { +func isRPCSupportedForLearner(req any) bool { switch r := req.(type) { case *pb.StatusRequest: return true diff --git a/etcdserver/etcdserverpb/rpc.pb.go b/etcdserver/etcdserverpb/rpc.pb.go index dddab02ac..9e6cfe62f 100644 --- a/etcdserver/etcdserverpb/rpc.pb.go +++ b/etcdserver/etcdserverpb/rpc.pb.go @@ -104,7 +104,9 @@ var RangeRequest_SortTarget_value = map[string]int32{ func (x RangeRequest_SortTarget) String() string { return proto.EnumName(RangeRequest_SortTarget_name, int32(x)) } -func (RangeRequest_SortTarget) EnumDescriptor() ([]byte, []int) { return fileDescriptorRpc, []int{1, 1} } +func (RangeRequest_SortTarget) EnumDescriptor() ([]byte, []int) { + return fileDescriptorRpc, []int{1, 1} +} type Compare_CompareResult int32 @@ -713,8 +715,8 @@ func (m *RequestOp) GetRequestTxn() *TxnRequest { } // XXX_OneofFuncs is for the internal use of the proto package. -func (*RequestOp) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _RequestOp_OneofMarshaler, _RequestOp_OneofUnmarshaler, _RequestOp_OneofSizer, []interface{}{ +func (*RequestOp) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []any) { + return _RequestOp_OneofMarshaler, _RequestOp_OneofUnmarshaler, _RequestOp_OneofSizer, []any{ (*RequestOp_RequestRange)(nil), (*RequestOp_RequestPut)(nil), (*RequestOp_RequestDeleteRange)(nil), @@ -900,8 +902,8 @@ func (m *ResponseOp) GetResponseTxn() *TxnResponse { } // XXX_OneofFuncs is for the internal use of the proto package. -func (*ResponseOp) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _ResponseOp_OneofMarshaler, _ResponseOp_OneofUnmarshaler, _ResponseOp_OneofSizer, []interface{}{ +func (*ResponseOp) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []any) { + return _ResponseOp_OneofMarshaler, _ResponseOp_OneofUnmarshaler, _ResponseOp_OneofSizer, []any{ (*ResponseOp_ResponseRange)(nil), (*ResponseOp_ResponsePut)(nil), (*ResponseOp_ResponseDeleteRange)(nil), @@ -1134,8 +1136,8 @@ func (m *Compare) GetRangeEnd() []byte { } // XXX_OneofFuncs is for the internal use of the proto package. -func (*Compare) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _Compare_OneofMarshaler, _Compare_OneofUnmarshaler, _Compare_OneofSizer, []interface{}{ +func (*Compare) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []any) { + return _Compare_OneofMarshaler, _Compare_OneofUnmarshaler, _Compare_OneofSizer, []any{ (*Compare_Version)(nil), (*Compare_CreateRevision)(nil), (*Compare_ModRevision)(nil), @@ -1567,8 +1569,8 @@ func (m *WatchRequest) GetProgressRequest() *WatchProgressRequest { } // XXX_OneofFuncs is for the internal use of the proto package. -func (*WatchRequest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _WatchRequest_OneofMarshaler, _WatchRequest_OneofUnmarshaler, _WatchRequest_OneofSizer, []interface{}{ +func (*WatchRequest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []any) { + return _WatchRequest_OneofMarshaler, _WatchRequest_OneofUnmarshaler, _WatchRequest_OneofSizer, []any{ (*WatchRequest_CreateRequest)(nil), (*WatchRequest_CancelRequest)(nil), (*WatchRequest_ProgressRequest)(nil), @@ -3669,7 +3671,7 @@ func RegisterKVServer(s *grpc.Server, srv KVServer) { s.RegisterService(&_KV_serviceDesc, srv) } -func _KV_Range_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _KV_Range_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(RangeRequest) if err := dec(in); err != nil { return nil, err @@ -3681,13 +3683,13 @@ func _KV_Range_Handler(srv interface{}, ctx context.Context, dec func(interface{ Server: srv, FullMethod: "/etcdserverpb.KV/Range", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(KVServer).Range(ctx, req.(*RangeRequest)) } return interceptor(ctx, in, info, handler) } -func _KV_Put_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _KV_Put_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(PutRequest) if err := dec(in); err != nil { return nil, err @@ -3699,13 +3701,13 @@ func _KV_Put_Handler(srv interface{}, ctx context.Context, dec func(interface{}) Server: srv, FullMethod: "/etcdserverpb.KV/Put", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(KVServer).Put(ctx, req.(*PutRequest)) } return interceptor(ctx, in, info, handler) } -func _KV_DeleteRange_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _KV_DeleteRange_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(DeleteRangeRequest) if err := dec(in); err != nil { return nil, err @@ -3717,13 +3719,13 @@ func _KV_DeleteRange_Handler(srv interface{}, ctx context.Context, dec func(inte Server: srv, FullMethod: "/etcdserverpb.KV/DeleteRange", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(KVServer).DeleteRange(ctx, req.(*DeleteRangeRequest)) } return interceptor(ctx, in, info, handler) } -func _KV_Txn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _KV_Txn_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(TxnRequest) if err := dec(in); err != nil { return nil, err @@ -3735,13 +3737,13 @@ func _KV_Txn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) Server: srv, FullMethod: "/etcdserverpb.KV/Txn", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(KVServer).Txn(ctx, req.(*TxnRequest)) } return interceptor(ctx, in, info, handler) } -func _KV_Compact_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _KV_Compact_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(CompactionRequest) if err := dec(in); err != nil { return nil, err @@ -3753,7 +3755,7 @@ func _KV_Compact_Handler(srv interface{}, ctx context.Context, dec func(interfac Server: srv, FullMethod: "/etcdserverpb.KV/Compact", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(KVServer).Compact(ctx, req.(*CompactionRequest)) } return interceptor(ctx, in, info, handler) @@ -3853,7 +3855,7 @@ func RegisterWatchServer(s *grpc.Server, srv WatchServer) { s.RegisterService(&_Watch_serviceDesc, srv) } -func _Watch_Watch_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Watch_Watch_Handler(srv any, stream grpc.ServerStream) error { return srv.(WatchServer).Watch(&watchWatchServer{stream}) } @@ -4009,7 +4011,7 @@ func RegisterLeaseServer(s *grpc.Server, srv LeaseServer) { s.RegisterService(&_Lease_serviceDesc, srv) } -func _Lease_LeaseGrant_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Lease_LeaseGrant_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(LeaseGrantRequest) if err := dec(in); err != nil { return nil, err @@ -4021,13 +4023,13 @@ func _Lease_LeaseGrant_Handler(srv interface{}, ctx context.Context, dec func(in Server: srv, FullMethod: "/etcdserverpb.Lease/LeaseGrant", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(LeaseServer).LeaseGrant(ctx, req.(*LeaseGrantRequest)) } return interceptor(ctx, in, info, handler) } -func _Lease_LeaseRevoke_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Lease_LeaseRevoke_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(LeaseRevokeRequest) if err := dec(in); err != nil { return nil, err @@ -4039,13 +4041,13 @@ func _Lease_LeaseRevoke_Handler(srv interface{}, ctx context.Context, dec func(i Server: srv, FullMethod: "/etcdserverpb.Lease/LeaseRevoke", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(LeaseServer).LeaseRevoke(ctx, req.(*LeaseRevokeRequest)) } return interceptor(ctx, in, info, handler) } -func _Lease_LeaseKeepAlive_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Lease_LeaseKeepAlive_Handler(srv any, stream grpc.ServerStream) error { return srv.(LeaseServer).LeaseKeepAlive(&leaseLeaseKeepAliveServer{stream}) } @@ -4071,7 +4073,7 @@ func (x *leaseLeaseKeepAliveServer) Recv() (*LeaseKeepAliveRequest, error) { return m, nil } -func _Lease_LeaseTimeToLive_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Lease_LeaseTimeToLive_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(LeaseTimeToLiveRequest) if err := dec(in); err != nil { return nil, err @@ -4083,13 +4085,13 @@ func _Lease_LeaseTimeToLive_Handler(srv interface{}, ctx context.Context, dec fu Server: srv, FullMethod: "/etcdserverpb.Lease/LeaseTimeToLive", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(LeaseServer).LeaseTimeToLive(ctx, req.(*LeaseTimeToLiveRequest)) } return interceptor(ctx, in, info, handler) } -func _Lease_LeaseLeases_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Lease_LeaseLeases_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(LeaseLeasesRequest) if err := dec(in); err != nil { return nil, err @@ -4101,7 +4103,7 @@ func _Lease_LeaseLeases_Handler(srv interface{}, ctx context.Context, dec func(i Server: srv, FullMethod: "/etcdserverpb.Lease/LeaseLeases", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(LeaseServer).LeaseLeases(ctx, req.(*LeaseLeasesRequest)) } return interceptor(ctx, in, info, handler) @@ -4226,7 +4228,7 @@ func RegisterClusterServer(s *grpc.Server, srv ClusterServer) { s.RegisterService(&_Cluster_serviceDesc, srv) } -func _Cluster_MemberAdd_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Cluster_MemberAdd_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(MemberAddRequest) if err := dec(in); err != nil { return nil, err @@ -4238,13 +4240,13 @@ func _Cluster_MemberAdd_Handler(srv interface{}, ctx context.Context, dec func(i Server: srv, FullMethod: "/etcdserverpb.Cluster/MemberAdd", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ClusterServer).MemberAdd(ctx, req.(*MemberAddRequest)) } return interceptor(ctx, in, info, handler) } -func _Cluster_MemberRemove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Cluster_MemberRemove_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(MemberRemoveRequest) if err := dec(in); err != nil { return nil, err @@ -4256,13 +4258,13 @@ func _Cluster_MemberRemove_Handler(srv interface{}, ctx context.Context, dec fun Server: srv, FullMethod: "/etcdserverpb.Cluster/MemberRemove", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ClusterServer).MemberRemove(ctx, req.(*MemberRemoveRequest)) } return interceptor(ctx, in, info, handler) } -func _Cluster_MemberUpdate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Cluster_MemberUpdate_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(MemberUpdateRequest) if err := dec(in); err != nil { return nil, err @@ -4274,13 +4276,13 @@ func _Cluster_MemberUpdate_Handler(srv interface{}, ctx context.Context, dec fun Server: srv, FullMethod: "/etcdserverpb.Cluster/MemberUpdate", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ClusterServer).MemberUpdate(ctx, req.(*MemberUpdateRequest)) } return interceptor(ctx, in, info, handler) } -func _Cluster_MemberList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Cluster_MemberList_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(MemberListRequest) if err := dec(in); err != nil { return nil, err @@ -4292,13 +4294,13 @@ func _Cluster_MemberList_Handler(srv interface{}, ctx context.Context, dec func( Server: srv, FullMethod: "/etcdserverpb.Cluster/MemberList", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ClusterServer).MemberList(ctx, req.(*MemberListRequest)) } return interceptor(ctx, in, info, handler) } -func _Cluster_MemberPromote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Cluster_MemberPromote_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(MemberPromoteRequest) if err := dec(in); err != nil { return nil, err @@ -4310,7 +4312,7 @@ func _Cluster_MemberPromote_Handler(srv interface{}, ctx context.Context, dec fu Server: srv, FullMethod: "/etcdserverpb.Cluster/MemberPromote", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ClusterServer).MemberPromote(ctx, req.(*MemberPromoteRequest)) } return interceptor(ctx, in, info, handler) @@ -4506,7 +4508,7 @@ func RegisterMaintenanceServer(s *grpc.Server, srv MaintenanceServer) { s.RegisterService(&_Maintenance_serviceDesc, srv) } -func _Maintenance_Alarm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Maintenance_Alarm_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(AlarmRequest) if err := dec(in); err != nil { return nil, err @@ -4518,13 +4520,13 @@ func _Maintenance_Alarm_Handler(srv interface{}, ctx context.Context, dec func(i Server: srv, FullMethod: "/etcdserverpb.Maintenance/Alarm", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(MaintenanceServer).Alarm(ctx, req.(*AlarmRequest)) } return interceptor(ctx, in, info, handler) } -func _Maintenance_Status_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Maintenance_Status_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(StatusRequest) if err := dec(in); err != nil { return nil, err @@ -4536,13 +4538,13 @@ func _Maintenance_Status_Handler(srv interface{}, ctx context.Context, dec func( Server: srv, FullMethod: "/etcdserverpb.Maintenance/Status", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(MaintenanceServer).Status(ctx, req.(*StatusRequest)) } return interceptor(ctx, in, info, handler) } -func _Maintenance_Defragment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Maintenance_Defragment_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(DefragmentRequest) if err := dec(in); err != nil { return nil, err @@ -4554,13 +4556,13 @@ func _Maintenance_Defragment_Handler(srv interface{}, ctx context.Context, dec f Server: srv, FullMethod: "/etcdserverpb.Maintenance/Defragment", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(MaintenanceServer).Defragment(ctx, req.(*DefragmentRequest)) } return interceptor(ctx, in, info, handler) } -func _Maintenance_Hash_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Maintenance_Hash_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(HashRequest) if err := dec(in); err != nil { return nil, err @@ -4572,13 +4574,13 @@ func _Maintenance_Hash_Handler(srv interface{}, ctx context.Context, dec func(in Server: srv, FullMethod: "/etcdserverpb.Maintenance/Hash", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(MaintenanceServer).Hash(ctx, req.(*HashRequest)) } return interceptor(ctx, in, info, handler) } -func _Maintenance_HashKV_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Maintenance_HashKV_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(HashKVRequest) if err := dec(in); err != nil { return nil, err @@ -4590,13 +4592,13 @@ func _Maintenance_HashKV_Handler(srv interface{}, ctx context.Context, dec func( Server: srv, FullMethod: "/etcdserverpb.Maintenance/HashKV", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(MaintenanceServer).HashKV(ctx, req.(*HashKVRequest)) } return interceptor(ctx, in, info, handler) } -func _Maintenance_Snapshot_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Maintenance_Snapshot_Handler(srv any, stream grpc.ServerStream) error { m := new(SnapshotRequest) if err := stream.RecvMsg(m); err != nil { return err @@ -4617,7 +4619,7 @@ func (x *maintenanceSnapshotServer) Send(m *SnapshotResponse) error { return x.ServerStream.SendMsg(m) } -func _Maintenance_MoveLeader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Maintenance_MoveLeader_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(MoveLeaderRequest) if err := dec(in); err != nil { return nil, err @@ -4629,13 +4631,13 @@ func _Maintenance_MoveLeader_Handler(srv interface{}, ctx context.Context, dec f Server: srv, FullMethod: "/etcdserverpb.Maintenance/MoveLeader", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(MaintenanceServer).MoveLeader(ctx, req.(*MoveLeaderRequest)) } return interceptor(ctx, in, info, handler) } -func _Maintenance_Downgrade_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Maintenance_Downgrade_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(DowngradeRequest) if err := dec(in); err != nil { return nil, err @@ -4647,7 +4649,7 @@ func _Maintenance_Downgrade_Handler(srv interface{}, ctx context.Context, dec fu Server: srv, FullMethod: "/etcdserverpb.Maintenance/Downgrade", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(MaintenanceServer).Downgrade(ctx, req.(*DowngradeRequest)) } return interceptor(ctx, in, info, handler) @@ -4939,7 +4941,7 @@ func RegisterAuthServer(s *grpc.Server, srv AuthServer) { s.RegisterService(&_Auth_serviceDesc, srv) } -func _Auth_AuthEnable_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Auth_AuthEnable_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(AuthEnableRequest) if err := dec(in); err != nil { return nil, err @@ -4951,13 +4953,13 @@ func _Auth_AuthEnable_Handler(srv interface{}, ctx context.Context, dec func(int Server: srv, FullMethod: "/etcdserverpb.Auth/AuthEnable", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AuthServer).AuthEnable(ctx, req.(*AuthEnableRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_AuthDisable_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Auth_AuthDisable_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(AuthDisableRequest) if err := dec(in); err != nil { return nil, err @@ -4969,13 +4971,13 @@ func _Auth_AuthDisable_Handler(srv interface{}, ctx context.Context, dec func(in Server: srv, FullMethod: "/etcdserverpb.Auth/AuthDisable", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AuthServer).AuthDisable(ctx, req.(*AuthDisableRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_AuthStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Auth_AuthStatus_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(AuthStatusRequest) if err := dec(in); err != nil { return nil, err @@ -4987,13 +4989,13 @@ func _Auth_AuthStatus_Handler(srv interface{}, ctx context.Context, dec func(int Server: srv, FullMethod: "/etcdserverpb.Auth/AuthStatus", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AuthServer).AuthStatus(ctx, req.(*AuthStatusRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_Authenticate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Auth_Authenticate_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(AuthenticateRequest) if err := dec(in); err != nil { return nil, err @@ -5005,13 +5007,13 @@ func _Auth_Authenticate_Handler(srv interface{}, ctx context.Context, dec func(i Server: srv, FullMethod: "/etcdserverpb.Auth/Authenticate", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AuthServer).Authenticate(ctx, req.(*AuthenticateRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_UserAdd_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Auth_UserAdd_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(AuthUserAddRequest) if err := dec(in); err != nil { return nil, err @@ -5023,13 +5025,13 @@ func _Auth_UserAdd_Handler(srv interface{}, ctx context.Context, dec func(interf Server: srv, FullMethod: "/etcdserverpb.Auth/UserAdd", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AuthServer).UserAdd(ctx, req.(*AuthUserAddRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_UserGet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Auth_UserGet_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(AuthUserGetRequest) if err := dec(in); err != nil { return nil, err @@ -5041,13 +5043,13 @@ func _Auth_UserGet_Handler(srv interface{}, ctx context.Context, dec func(interf Server: srv, FullMethod: "/etcdserverpb.Auth/UserGet", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AuthServer).UserGet(ctx, req.(*AuthUserGetRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_UserList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Auth_UserList_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(AuthUserListRequest) if err := dec(in); err != nil { return nil, err @@ -5059,13 +5061,13 @@ func _Auth_UserList_Handler(srv interface{}, ctx context.Context, dec func(inter Server: srv, FullMethod: "/etcdserverpb.Auth/UserList", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AuthServer).UserList(ctx, req.(*AuthUserListRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_UserDelete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Auth_UserDelete_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(AuthUserDeleteRequest) if err := dec(in); err != nil { return nil, err @@ -5077,13 +5079,13 @@ func _Auth_UserDelete_Handler(srv interface{}, ctx context.Context, dec func(int Server: srv, FullMethod: "/etcdserverpb.Auth/UserDelete", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AuthServer).UserDelete(ctx, req.(*AuthUserDeleteRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_UserChangePassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Auth_UserChangePassword_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(AuthUserChangePasswordRequest) if err := dec(in); err != nil { return nil, err @@ -5095,13 +5097,13 @@ func _Auth_UserChangePassword_Handler(srv interface{}, ctx context.Context, dec Server: srv, FullMethod: "/etcdserverpb.Auth/UserChangePassword", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AuthServer).UserChangePassword(ctx, req.(*AuthUserChangePasswordRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_UserGrantRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Auth_UserGrantRole_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(AuthUserGrantRoleRequest) if err := dec(in); err != nil { return nil, err @@ -5113,13 +5115,13 @@ func _Auth_UserGrantRole_Handler(srv interface{}, ctx context.Context, dec func( Server: srv, FullMethod: "/etcdserverpb.Auth/UserGrantRole", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AuthServer).UserGrantRole(ctx, req.(*AuthUserGrantRoleRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_UserRevokeRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Auth_UserRevokeRole_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(AuthUserRevokeRoleRequest) if err := dec(in); err != nil { return nil, err @@ -5131,13 +5133,13 @@ func _Auth_UserRevokeRole_Handler(srv interface{}, ctx context.Context, dec func Server: srv, FullMethod: "/etcdserverpb.Auth/UserRevokeRole", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AuthServer).UserRevokeRole(ctx, req.(*AuthUserRevokeRoleRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_RoleAdd_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Auth_RoleAdd_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(AuthRoleAddRequest) if err := dec(in); err != nil { return nil, err @@ -5149,13 +5151,13 @@ func _Auth_RoleAdd_Handler(srv interface{}, ctx context.Context, dec func(interf Server: srv, FullMethod: "/etcdserverpb.Auth/RoleAdd", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AuthServer).RoleAdd(ctx, req.(*AuthRoleAddRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_RoleGet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Auth_RoleGet_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(AuthRoleGetRequest) if err := dec(in); err != nil { return nil, err @@ -5167,13 +5169,13 @@ func _Auth_RoleGet_Handler(srv interface{}, ctx context.Context, dec func(interf Server: srv, FullMethod: "/etcdserverpb.Auth/RoleGet", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AuthServer).RoleGet(ctx, req.(*AuthRoleGetRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_RoleList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Auth_RoleList_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(AuthRoleListRequest) if err := dec(in); err != nil { return nil, err @@ -5185,13 +5187,13 @@ func _Auth_RoleList_Handler(srv interface{}, ctx context.Context, dec func(inter Server: srv, FullMethod: "/etcdserverpb.Auth/RoleList", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AuthServer).RoleList(ctx, req.(*AuthRoleListRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_RoleDelete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Auth_RoleDelete_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(AuthRoleDeleteRequest) if err := dec(in); err != nil { return nil, err @@ -5203,13 +5205,13 @@ func _Auth_RoleDelete_Handler(srv interface{}, ctx context.Context, dec func(int Server: srv, FullMethod: "/etcdserverpb.Auth/RoleDelete", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AuthServer).RoleDelete(ctx, req.(*AuthRoleDeleteRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_RoleGrantPermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Auth_RoleGrantPermission_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(AuthRoleGrantPermissionRequest) if err := dec(in); err != nil { return nil, err @@ -5221,13 +5223,13 @@ func _Auth_RoleGrantPermission_Handler(srv interface{}, ctx context.Context, dec Server: srv, FullMethod: "/etcdserverpb.Auth/RoleGrantPermission", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AuthServer).RoleGrantPermission(ctx, req.(*AuthRoleGrantPermissionRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_RoleRevokePermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Auth_RoleRevokePermission_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(AuthRoleRevokePermissionRequest) if err := dec(in); err != nil { return nil, err @@ -5239,7 +5241,7 @@ func _Auth_RoleRevokePermission_Handler(srv interface{}, ctx context.Context, de Server: srv, FullMethod: "/etcdserverpb.Auth/RoleRevokePermission", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AuthServer).RoleRevokePermission(ctx, req.(*AuthRoleRevokePermissionRequest)) } return interceptor(ctx, in, info, handler) diff --git a/etcdserver/quota.go b/etcdserver/quota.go index 4727ac14a..87678a11f 100644 --- a/etcdserver/quota.go +++ b/etcdserver/quota.go @@ -37,18 +37,18 @@ const ( // too few resources available within the quota to apply the request. type Quota interface { // Available judges whether the given request fits within the quota. - Available(req interface{}) bool + Available(req any) bool // Cost computes the charge against the quota for a given request. - Cost(req interface{}) int + Cost(req any) int // Remaining is the amount of charge left for the quota. Remaining() int64 } type passthroughQuota struct{} -func (*passthroughQuota) Available(interface{}) bool { return true } -func (*passthroughQuota) Cost(interface{}) int { return 0 } -func (*passthroughQuota) Remaining() int64 { return 1 } +func (*passthroughQuota) Available(any) bool { return true } +func (*passthroughQuota) Cost(any) int { return 0 } +func (*passthroughQuota) Remaining() int64 { return 1 } type backendQuota struct { s *EtcdServer @@ -124,12 +124,12 @@ func NewBackendQuota(s *EtcdServer, name string) Quota { return &backendQuota{s, s.Cfg.QuotaBackendBytes} } -func (b *backendQuota) Available(v interface{}) bool { +func (b *backendQuota) Available(v any) bool { // TODO: maybe optimize backend.Size() return b.s.Backend().Size()+int64(b.Cost(v)) < b.maxBackendBytes } -func (b *backendQuota) Cost(v interface{}) int { +func (b *backendQuota) Cost(v any) int { switch r := v.(type) { case *pb.PutRequest: return costPut(r) diff --git a/etcdserver/raft.go b/etcdserver/raft.go index 872015dfb..aa678b7ad 100644 --- a/etcdserver/raft.go +++ b/etcdserver/raft.go @@ -58,7 +58,7 @@ var ( ) func init() { - expvar.Publish("raft.status", expvar.Func(func() interface{} { + expvar.Publish("raft.status", expvar.Func(func() any { raftStatusMu.Lock() defer raftStatusMu.Unlock() return raftStatus() diff --git a/etcdserver/server.go b/etcdserver/server.go index 33f7db068..9167a1ec6 100644 --- a/etcdserver/server.go +++ b/etcdserver/server.go @@ -113,7 +113,7 @@ func init() { expvar.Publish( "file_descriptor_limit", expvar.Func( - func() interface{} { + func() any { n, _ := runtime.FDLimit() return n }, diff --git a/etcdserver/server_test.go b/etcdserver/server_test.go index 85e474a69..f00983f5a 100644 --- a/etcdserver/server_test.go +++ b/etcdserver/server_test.go @@ -70,7 +70,7 @@ func TestDoLocalAction(t *testing.T) { []testutil.Action{ { Name: "Get", - Params: []interface{}{"", false, false}, + Params: []any{"", false, false}, }, }, }, @@ -80,7 +80,7 @@ func TestDoLocalAction(t *testing.T) { []testutil.Action{ { Name: "Get", - Params: []interface{}{"", false, false}, + Params: []any{"", false, false}, }, }, }, @@ -130,7 +130,7 @@ func TestDoBadLocalAction(t *testing.T) { []testutil.Action{ { Name: "Get", - Params: []interface{}{"", false, false}, + Params: []any{"", false, false}, }, }, }, @@ -139,7 +139,7 @@ func TestDoBadLocalAction(t *testing.T) { []testutil.Action{ { Name: "Get", - Params: []interface{}{"", false, false}, + Params: []any{"", false, false}, }, }, }, @@ -248,7 +248,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "Create", - Params: []interface{}{"", false, "", true, v2store.TTLOptionSet{ExpireTime: time.Time{}}}, + Params: []any{"", false, "", true, v2store.TTLOptionSet{ExpireTime: time.Time{}}}, }, }, }, @@ -259,7 +259,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "Create", - Params: []interface{}{"", false, "", true, v2store.TTLOptionSet{ExpireTime: time.Unix(0, 1337)}}, + Params: []any{"", false, "", true, v2store.TTLOptionSet{ExpireTime: time.Unix(0, 1337)}}, }, }, }, @@ -270,7 +270,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "Create", - Params: []interface{}{"", true, "", true, v2store.TTLOptionSet{ExpireTime: time.Time{}}}, + Params: []any{"", true, "", true, v2store.TTLOptionSet{ExpireTime: time.Time{}}}, }, }, }, @@ -281,7 +281,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "Set", - Params: []interface{}{"", false, "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, + Params: []any{"", false, "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, }, }, }, @@ -292,7 +292,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "Set", - Params: []interface{}{"", true, "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, + Params: []any{"", true, "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, }, }, }, @@ -303,7 +303,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "Update", - Params: []interface{}{"", "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, + Params: []any{"", "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, }, }, }, @@ -314,7 +314,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "Create", - Params: []interface{}{"", false, "", false, v2store.TTLOptionSet{ExpireTime: time.Time{}}}, + Params: []any{"", false, "", false, v2store.TTLOptionSet{ExpireTime: time.Time{}}}, }, }, }, @@ -325,7 +325,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "CompareAndSwap", - Params: []interface{}{"", "", uint64(1), "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, + Params: []any{"", "", uint64(1), "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, }, }, }, @@ -336,7 +336,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "Create", - Params: []interface{}{"", false, "", false, v2store.TTLOptionSet{ExpireTime: time.Time{}}}, + Params: []any{"", false, "", false, v2store.TTLOptionSet{ExpireTime: time.Time{}}}, }, }, }, @@ -347,7 +347,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "CompareAndSwap", - Params: []interface{}{"", "", uint64(1), "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, + Params: []any{"", "", uint64(1), "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, }, }, }, @@ -358,7 +358,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "CompareAndSwap", - Params: []interface{}{"", "bar", uint64(0), "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, + Params: []any{"", "bar", uint64(0), "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, }, }, }, @@ -369,7 +369,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "CompareAndSwap", - Params: []interface{}{"", "bar", uint64(1), "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, + Params: []any{"", "bar", uint64(1), "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, }, }, }, @@ -380,7 +380,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "Delete", - Params: []interface{}{"", false, false}, + Params: []any{"", false, false}, }, }, }, @@ -391,7 +391,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "CompareAndDelete", - Params: []interface{}{"", "", uint64(1)}, + Params: []any{"", "", uint64(1)}, }, }, }, @@ -402,7 +402,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "CompareAndDelete", - Params: []interface{}{"", "bar", uint64(0)}, + Params: []any{"", "bar", uint64(0)}, }, }, }, @@ -413,7 +413,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "CompareAndDelete", - Params: []interface{}{"", "bar", uint64(5)}, + Params: []any{"", "bar", uint64(5)}, }, }, }, @@ -424,7 +424,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "Get", - Params: []interface{}{"", false, false}, + Params: []any{"", false, false}, }, }, }, @@ -435,7 +435,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "DeleteExpiredKeys", - Params: []interface{}{time.Unix(0, 0)}, + Params: []any{time.Unix(0, 0)}, }, }, }, @@ -445,7 +445,7 @@ func TestApplyRequest(t *testing.T) { []testutil.Action{ { Name: "DeleteExpiredKeys", - Params: []interface{}{time.Unix(0, 12345)}, + Params: []any{time.Unix(0, 12345)}, }, }, }, @@ -579,7 +579,7 @@ func TestApplyConfChangeError(t *testing.T) { w := []testutil.Action{ { Name: "ApplyConfChange", - Params: []interface{}{cc}, + Params: []any{cc}, }, } if g, _ := n.Wait(1); !reflect.DeepEqual(g, w) { @@ -1398,7 +1398,7 @@ func TestUpdateMember(t *testing.T) { func TestPublish(t *testing.T) { n := newNodeRecorder() - ch := make(chan interface{}, 1) + ch := make(chan any, 1) // simulate that request has gone through consensus ch <- Response{} w := wait.NewWithResponse(ch) @@ -1592,7 +1592,7 @@ func (n *nodeRecorder) Campaign(ctx context.Context) error { return nil } func (n *nodeRecorder) Propose(ctx context.Context, data []byte) error { - n.Record(testutil.Action{Name: "Propose", Params: []interface{}{data}}) + n.Record(testutil.Action{Name: "Propose", Params: []any{data}}) return nil } func (n *nodeRecorder) ProposeConfChange(ctx context.Context, conf raftpb.ConfChangeI) error { @@ -1609,7 +1609,7 @@ func (n *nodeRecorder) TransferLeadership(ctx context.Context, lead, transferee func (n *nodeRecorder) ReadIndex(ctx context.Context, rctx []byte) error { return nil } func (n *nodeRecorder) Advance() {} func (n *nodeRecorder) ApplyConfChange(conf raftpb.ConfChangeI) *raftpb.ConfState { - n.Record(testutil.Action{Name: "ApplyConfChange", Params: []interface{}{conf}}) + n.Record(testutil.Action{Name: "ApplyConfChange", Params: []any{conf}}) return &raftpb.ConfState{} } diff --git a/functional/rpcpb/rpc.pb.go b/functional/rpcpb/rpc.pb.go index 12be4d2bb..02a3ffd3e 100644 --- a/functional/rpcpb/rpc.pb.go +++ b/functional/rpcpb/rpc.pb.go @@ -1299,7 +1299,7 @@ func RegisterTransportServer(s *grpc.Server, srv TransportServer) { s.RegisterService(&_Transport_serviceDesc, srv) } -func _Transport_Transport_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Transport_Transport_Handler(srv any, stream grpc.ServerStream) error { return srv.(TransportServer).Transport(&transportTransportServer{stream}) } diff --git a/integration/v2_http_kv_test.go b/integration/v2_http_kv_test.go index daaac25db..89f40f2ee 100644 --- a/integration/v2_http_kv_test.go +++ b/integration/v2_http_kv_test.go @@ -105,15 +105,15 @@ func TestV2CreateUpdate(t *testing.T) { relativeURL string value url.Values wStatus int - w map[string]interface{} + w map[string]any }{ // key with ttl { "/v2/keys/ttl/foo", url.Values(map[string][]string{"value": {"XXX"}, "ttl": {"20"}}), http.StatusCreated, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "value": "XXX", "ttl": float64(20), }, @@ -124,7 +124,7 @@ func TestV2CreateUpdate(t *testing.T) { "/v2/keys/ttl/foo", url.Values(map[string][]string{"value": {"XXX"}, "ttl": {"bad_ttl"}}), http.StatusBadRequest, - map[string]interface{}{ + map[string]any{ "errorCode": float64(202), "message": "The given TTL in POST form is not a number", }, @@ -134,8 +134,8 @@ func TestV2CreateUpdate(t *testing.T) { "/v2/keys/create/foo", url.Values(map[string][]string{"value": {"XXX"}, "prevExist": {"false"}}), http.StatusCreated, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "value": "XXX", }, }, @@ -145,7 +145,7 @@ func TestV2CreateUpdate(t *testing.T) { "/v2/keys/create/foo", url.Values(map[string][]string{"value": {"XXX"}, "prevExist": {"false"}}), http.StatusPreconditionFailed, - map[string]interface{}{ + map[string]any{ "errorCode": float64(105), "message": "Key already exists", "cause": "/create/foo", @@ -156,8 +156,8 @@ func TestV2CreateUpdate(t *testing.T) { "/v2/keys/create/foo", url.Values(map[string][]string{"value": {"YYY"}, "prevExist": {"true"}, "ttl": {"20"}}), http.StatusOK, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "value": "YYY", "ttl": float64(20), }, @@ -169,8 +169,8 @@ func TestV2CreateUpdate(t *testing.T) { "/v2/keys/create/foo", url.Values(map[string][]string{"value": {"ZZZ"}, "prevExist": {"true"}}), http.StatusOK, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "value": "ZZZ", }, "action": "update", @@ -181,7 +181,7 @@ func TestV2CreateUpdate(t *testing.T) { "/v2/keys/nonexist", url.Values(map[string][]string{"value": {"XXX"}, "prevExist": {"true"}}), http.StatusNotFound, - map[string]interface{}{ + map[string]any{ "errorCode": float64(100), "message": "Key not found", "cause": "/nonexist", @@ -192,21 +192,21 @@ func TestV2CreateUpdate(t *testing.T) { "/v2/keys/create/novalue", url.Values(map[string][]string{"value": {"XXX"}, "prevExist": {"false"}, "noValueOnSuccess": {"true"}}), http.StatusCreated, - map[string]interface{}{}, + map[string]any{}, }, // update with no value on success { "/v2/keys/create/novalue", url.Values(map[string][]string{"value": {"XXX"}, "prevExist": {"true"}, "noValueOnSuccess": {"true"}}), http.StatusOK, - map[string]interface{}{}, + map[string]any{}, }, // created key failed with no value on success { "/v2/keys/create/foo", url.Values(map[string][]string{"value": {"XXX"}, "prevExist": {"false"}, "noValueOnSuccess": {"true"}}), http.StatusPreconditionFailed, - map[string]interface{}{ + map[string]any{ "errorCode": float64(105), "message": "Key already exists", "cause": "/create/foo", @@ -241,7 +241,7 @@ func TestV2CAS(t *testing.T) { relativeURL string value url.Values wStatus int - w map[string]interface{} + w map[string]any }{ { "/v2/keys/cas/foo", @@ -253,8 +253,8 @@ func TestV2CAS(t *testing.T) { "/v2/keys/cas/foo", url.Values(map[string][]string{"value": {"YYY"}, "prevIndex": {"4"}}), http.StatusOK, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "value": "YYY", "modifiedIndex": float64(5), }, @@ -265,7 +265,7 @@ func TestV2CAS(t *testing.T) { "/v2/keys/cas/foo", url.Values(map[string][]string{"value": {"YYY"}, "prevIndex": {"10"}}), http.StatusPreconditionFailed, - map[string]interface{}{ + map[string]any{ "errorCode": float64(101), "message": "Compare failed", "cause": "[10 != 5]", @@ -276,7 +276,7 @@ func TestV2CAS(t *testing.T) { "/v2/keys/cas/foo", url.Values(map[string][]string{"value": {"YYY"}, "prevIndex": {"bad_index"}}), http.StatusBadRequest, - map[string]interface{}{ + map[string]any{ "errorCode": float64(203), "message": "The given index in POST form is not a number", }, @@ -285,8 +285,8 @@ func TestV2CAS(t *testing.T) { "/v2/keys/cas/foo", url.Values(map[string][]string{"value": {"ZZZ"}, "prevValue": {"YYY"}}), http.StatusOK, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "value": "ZZZ", }, "action": "compareAndSwap", @@ -296,7 +296,7 @@ func TestV2CAS(t *testing.T) { "/v2/keys/cas/foo", url.Values(map[string][]string{"value": {"XXX"}, "prevValue": {"bad_value"}}), http.StatusPreconditionFailed, - map[string]interface{}{ + map[string]any{ "errorCode": float64(101), "message": "Compare failed", "cause": "[bad_value != ZZZ]", @@ -307,7 +307,7 @@ func TestV2CAS(t *testing.T) { "/v2/keys/cas/foo", url.Values(map[string][]string{"value": {"XXX"}, "prevValue": {""}}), http.StatusBadRequest, - map[string]interface{}{ + map[string]any{ "errorCode": float64(201), }, }, @@ -315,7 +315,7 @@ func TestV2CAS(t *testing.T) { "/v2/keys/cas/foo", url.Values(map[string][]string{"value": {"XXX"}, "prevValue": {"bad_value"}, "prevIndex": {"100"}}), http.StatusPreconditionFailed, - map[string]interface{}{ + map[string]any{ "errorCode": float64(101), "message": "Compare failed", "cause": "[bad_value != ZZZ] [100 != 6]", @@ -325,7 +325,7 @@ func TestV2CAS(t *testing.T) { "/v2/keys/cas/foo", url.Values(map[string][]string{"value": {"XXX"}, "prevValue": {"ZZZ"}, "prevIndex": {"100"}}), http.StatusPreconditionFailed, - map[string]interface{}{ + map[string]any{ "errorCode": float64(101), "message": "Compare failed", "cause": "[100 != 6]", @@ -335,7 +335,7 @@ func TestV2CAS(t *testing.T) { "/v2/keys/cas/foo", url.Values(map[string][]string{"value": {"XXX"}, "prevValue": {"bad_value"}, "prevIndex": {"6"}}), http.StatusPreconditionFailed, - map[string]interface{}{ + map[string]any{ "errorCode": float64(101), "message": "Compare failed", "cause": "[bad_value != ZZZ]", @@ -345,7 +345,7 @@ func TestV2CAS(t *testing.T) { "/v2/keys/cas/foo", url.Values(map[string][]string{"value": {"YYY"}, "prevIndex": {"6"}, "noValueOnSuccess": {"true"}}), http.StatusOK, - map[string]interface{}{ + map[string]any{ "action": "compareAndSwap", }, }, @@ -353,7 +353,7 @@ func TestV2CAS(t *testing.T) { "/v2/keys/cas/foo", url.Values(map[string][]string{"value": {"YYY"}, "prevIndex": {"10"}, "noValueOnSuccess": {"true"}}), http.StatusPreconditionFailed, - map[string]interface{}{ + map[string]any{ "errorCode": float64(101), "message": "Compare failed", "cause": "[10 != 7]", @@ -406,16 +406,16 @@ func TestV2Delete(t *testing.T) { tests := []struct { relativeURL string wStatus int - w map[string]interface{} + w map[string]any }{ { "/v2/keys/foo", http.StatusOK, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "key": "/foo", }, - "prevNode": map[string]interface{}{ + "prevNode": map[string]any{ "key": "/foo", "value": "XXX", }, @@ -425,7 +425,7 @@ func TestV2Delete(t *testing.T) { { "/v2/keys/emptydir", http.StatusForbidden, - map[string]interface{}{ + map[string]any{ "errorCode": float64(102), "message": "Not a file", "cause": "/emptydir", @@ -439,7 +439,7 @@ func TestV2Delete(t *testing.T) { { "/v2/keys/foodir?dir=true", http.StatusForbidden, - map[string]interface{}{ + map[string]any{ "errorCode": float64(108), "message": "Directory not empty", "cause": "/foodir", @@ -448,12 +448,12 @@ func TestV2Delete(t *testing.T) { { "/v2/keys/foodir?recursive=true", http.StatusOK, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "key": "/foodir", "dir": true, }, - "prevNode": map[string]interface{}{ + "prevNode": map[string]any{ "key": "/foodir", "dir": true, }, @@ -502,12 +502,12 @@ func TestV2CAD(t *testing.T) { tests := []struct { relativeURL string wStatus int - w map[string]interface{} + w map[string]any }{ { "/v2/keys/foo?prevIndex=100", http.StatusPreconditionFailed, - map[string]interface{}{ + map[string]any{ "errorCode": float64(101), "message": "Compare failed", "cause": "[100 != 4]", @@ -516,7 +516,7 @@ func TestV2CAD(t *testing.T) { { "/v2/keys/foo?prevIndex=bad_index", http.StatusBadRequest, - map[string]interface{}{ + map[string]any{ "errorCode": float64(203), "message": "The given index in POST form is not a number", }, @@ -524,8 +524,8 @@ func TestV2CAD(t *testing.T) { { "/v2/keys/foo?prevIndex=4", http.StatusOK, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "key": "/foo", "modifiedIndex": float64(6), }, @@ -535,7 +535,7 @@ func TestV2CAD(t *testing.T) { { "/v2/keys/foovalue?prevValue=YYY", http.StatusPreconditionFailed, - map[string]interface{}{ + map[string]any{ "errorCode": float64(101), "message": "Compare failed", "cause": "[YYY != XXX]", @@ -544,7 +544,7 @@ func TestV2CAD(t *testing.T) { { "/v2/keys/foovalue?prevValue=", http.StatusBadRequest, - map[string]interface{}{ + map[string]any{ "errorCode": float64(201), "cause": `"prevValue" cannot be empty`, }, @@ -552,8 +552,8 @@ func TestV2CAD(t *testing.T) { { "/v2/keys/foovalue?prevValue=XXX", http.StatusOK, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "key": "/foovalue", "modifiedIndex": float64(7), }, @@ -589,14 +589,14 @@ func TestV2Unique(t *testing.T) { relativeURL string value url.Values wStatus int - w map[string]interface{} + w map[string]any }{ { "/v2/keys/foo", url.Values(map[string][]string{"value": {"XXX"}}), http.StatusCreated, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "key": "/foo/00000000000000000004", "value": "XXX", }, @@ -607,8 +607,8 @@ func TestV2Unique(t *testing.T) { "/v2/keys/foo", url.Values(map[string][]string{"value": {"XXX"}}), http.StatusCreated, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "key": "/foo/00000000000000000005", "value": "XXX", }, @@ -619,8 +619,8 @@ func TestV2Unique(t *testing.T) { "/v2/keys/bar", url.Values(map[string][]string{"value": {"XXX"}}), http.StatusCreated, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "key": "/bar/00000000000000000006", "value": "XXX", }, @@ -663,13 +663,13 @@ func TestV2Get(t *testing.T) { tests := []struct { relativeURL string wStatus int - w map[string]interface{} + w map[string]any }{ { "/v2/keys/foo/bar/zar", http.StatusOK, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "key": "/foo/bar/zar", "value": "XXX", }, @@ -679,12 +679,12 @@ func TestV2Get(t *testing.T) { { "/v2/keys/foo", http.StatusOK, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "key": "/foo", "dir": true, - "nodes": []interface{}{ - map[string]interface{}{ + "nodes": []any{ + map[string]any{ "key": "/foo/bar", "dir": true, "createdIndex": float64(4), @@ -698,18 +698,18 @@ func TestV2Get(t *testing.T) { { "/v2/keys/foo?recursive=true", http.StatusOK, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "key": "/foo", "dir": true, - "nodes": []interface{}{ - map[string]interface{}{ + "nodes": []any{ + map[string]any{ "key": "/foo/bar", "dir": true, "createdIndex": float64(4), "modifiedIndex": float64(4), - "nodes": []interface{}{ - map[string]interface{}{ + "nodes": []any{ + map[string]any{ "key": "/foo/bar/zar", "value": "XXX", "createdIndex": float64(4), @@ -761,13 +761,13 @@ func TestV2QuorumGet(t *testing.T) { tests := []struct { relativeURL string wStatus int - w map[string]interface{} + w map[string]any }{ { "/v2/keys/foo/bar/zar", http.StatusOK, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "key": "/foo/bar/zar", "value": "XXX", }, @@ -777,12 +777,12 @@ func TestV2QuorumGet(t *testing.T) { { "/v2/keys/foo", http.StatusOK, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "key": "/foo", "dir": true, - "nodes": []interface{}{ - map[string]interface{}{ + "nodes": []any{ + map[string]any{ "key": "/foo/bar", "dir": true, "createdIndex": float64(4), @@ -796,18 +796,18 @@ func TestV2QuorumGet(t *testing.T) { { "/v2/keys/foo?recursive=true", http.StatusOK, - map[string]interface{}{ - "node": map[string]interface{}{ + map[string]any{ + "node": map[string]any{ "key": "/foo", "dir": true, - "nodes": []interface{}{ - map[string]interface{}{ + "nodes": []any{ + map[string]any{ "key": "/foo/bar", "dir": true, "createdIndex": float64(4), "modifiedIndex": float64(4), - "nodes": []interface{}{ - map[string]interface{}{ + "nodes": []any{ + map[string]any{ "key": "/foo/bar/zar", "value": "XXX", "createdIndex": float64(4), @@ -863,8 +863,8 @@ func TestV2Watch(t *testing.T) { resp.Body.Close() body := tc.ReadBodyJSON(watchResp) - w := map[string]interface{}{ - "node": map[string]interface{}{ + w := map[string]any{ + "node": map[string]any{ "key": "/foo/bar", "value": "XXX", "modifiedIndex": float64(4), @@ -886,7 +886,7 @@ func TestV2WatchWithIndex(t *testing.T) { u := cl.URL(0) tc := NewTestClient() - var body map[string]interface{} + var body map[string]any c := make(chan bool, 1) go func() { resp, err := tc.Get(fmt.Sprintf("%s%s", u, "/v2/keys/foo/bar?wait=true&waitIndex=5")) @@ -931,8 +931,8 @@ func TestV2WatchWithIndex(t *testing.T) { t.Fatal("cannot get watch result") } - w := map[string]interface{}{ - "node": map[string]interface{}{ + w := map[string]any{ + "node": map[string]any{ "key": "/foo/bar", "value": "XXX", "modifiedIndex": float64(5), @@ -953,7 +953,7 @@ func TestV2WatchKeyInDir(t *testing.T) { u := cl.URL(0) tc := NewTestClient() - var body map[string]interface{} + var body map[string]any c := make(chan bool) // Create an expiring directory @@ -994,8 +994,8 @@ func TestV2WatchKeyInDir(t *testing.T) { t.Fatal("timed out waiting for watch result") } - w := map[string]interface{}{ - "node": map[string]interface{}{ + w := map[string]any{ + "node": map[string]any{ "key": "/keyindir", }, "action": "expire", @@ -1048,11 +1048,11 @@ func TestV2Head(t *testing.T) { } } -func checkBody(body map[string]interface{}, w map[string]interface{}) error { +func checkBody(body map[string]any, w map[string]any) error { if body["node"] != nil { if w["node"] != nil { - wn := w["node"].(map[string]interface{}) - n := body["node"].(map[string]interface{}) + wn := w["node"].(map[string]any) + n := body["node"].(map[string]any) for k := range n { if wn[k] == nil { delete(n, k) @@ -1061,8 +1061,8 @@ func checkBody(body map[string]interface{}, w map[string]interface{}) error { body["node"] = n } if w["prevNode"] != nil { - wn := w["prevNode"].(map[string]interface{}) - n := body["prevNode"].(map[string]interface{}) + wn := w["prevNode"].(map[string]any) + n := body["prevNode"].(map[string]any) for k := range n { if wn[k] == nil { delete(n, k) @@ -1102,8 +1102,8 @@ func (t *testHttpClient) ReadBody(resp *http.Response) []byte { } // Reads the body from the response and parses it as JSON. -func (t *testHttpClient) ReadBodyJSON(resp *http.Response) map[string]interface{} { - m := make(map[string]interface{}) +func (t *testHttpClient) ReadBodyJSON(resp *http.Response) map[string]any { + m := make(map[string]any) b := t.ReadBody(resp) if err := json.Unmarshal(b, &m); err != nil { panic(fmt.Sprintf("HTTP body JSON parse error: %v: %s", err, string(b))) diff --git a/lease/lease_queue.go b/lease/lease_queue.go index 17ddb358e..bef64ba2b 100644 --- a/lease/lease_queue.go +++ b/lease/lease_queue.go @@ -40,14 +40,14 @@ func (pq LeaseQueue) Swap(i, j int) { pq[j].index = j } -func (pq *LeaseQueue) Push(x interface{}) { +func (pq *LeaseQueue) Push(x any) { n := len(*pq) item := x.(*LeaseWithTime) item.index = n *pq = append(*pq, item) } -func (pq *LeaseQueue) Pop() interface{} { +func (pq *LeaseQueue) Pop() any { old := *pq n := len(old) item := old[n-1] diff --git a/mvcc/kvstore_test.go b/mvcc/kvstore_test.go index 4478be951..f64762875 100644 --- a/mvcc/kvstore_test.go +++ b/mvcc/kvstore_test.go @@ -147,12 +147,12 @@ func TestStorePut(t *testing.T) { } wact := []testutil.Action{ - {Name: "seqput", Params: []interface{}{keyBucketName, tt.wkey, data}}, + {Name: "seqput", Params: []any{keyBucketName, tt.wkey, data}}, } if tt.rr != nil { wact = []testutil.Action{ - {Name: "seqput", Params: []interface{}{keyBucketName, tt.wkey, data}}, + {Name: "seqput", Params: []any{keyBucketName, tt.wkey, data}}, } } @@ -160,8 +160,8 @@ func TestStorePut(t *testing.T) { t.Errorf("#%d: tx action = %+v, want %+v", i, g, wact) } wact = []testutil.Action{ - {Name: "get", Params: []interface{}{[]byte("foo"), tt.wputrev.main}}, - {Name: "put", Params: []interface{}{[]byte("foo"), tt.wputrev}}, + {Name: "get", Params: []any{[]byte("foo"), tt.wputrev.main}}, + {Name: "put", Params: []any{[]byte("foo"), tt.wputrev}}, } if g := fi.Action(); !reflect.DeepEqual(g, wact) { t.Errorf("#%d: index action = %+v, want %+v", i, g, wact) @@ -227,13 +227,13 @@ func TestStoreRange(t *testing.T) { wstart := newRevBytes() revToBytes(tt.idxr.revs[0], wstart) wact := []testutil.Action{ - {Name: "range", Params: []interface{}{keyBucketName, wstart, []byte(nil), int64(0)}}, + {Name: "range", Params: []any{keyBucketName, wstart, []byte(nil), int64(0)}}, } if g := b.tx.Action(); !reflect.DeepEqual(g, wact) { t.Errorf("#%d: tx action = %+v, want %+v", i, g, wact) } wact = []testutil.Action{ - {Name: "range", Params: []interface{}{[]byte("foo"), []byte("goo"), wrev}}, + {Name: "range", Params: []any{[]byte("foo"), []byte("goo"), wrev}}, } if g := fi.Action(); !reflect.DeepEqual(g, wact) { t.Errorf("#%d: index action = %+v, want %+v", i, g, wact) @@ -302,14 +302,14 @@ func TestStoreDeleteRange(t *testing.T) { t.Errorf("#%d: marshal err = %v, want nil", i, err) } wact := []testutil.Action{ - {Name: "seqput", Params: []interface{}{keyBucketName, tt.wkey, data}}, + {Name: "seqput", Params: []any{keyBucketName, tt.wkey, data}}, } if g := b.tx.Action(); !reflect.DeepEqual(g, wact) { t.Errorf("#%d: tx action = %+v, want %+v", i, g, wact) } wact = []testutil.Action{ - {Name: "range", Params: []interface{}{[]byte("foo"), []byte("goo"), tt.wrrev}}, - {Name: "tombstone", Params: []interface{}{[]byte("foo"), tt.wdelrev}}, + {Name: "range", Params: []any{[]byte("foo"), []byte("goo"), tt.wrrev}}, + {Name: "tombstone", Params: []any{[]byte("foo"), tt.wdelrev}}, } if g := fi.Action(); !reflect.DeepEqual(g, wact) { t.Errorf("#%d: index action = %+v, want %+v", i, g, wact) @@ -341,16 +341,16 @@ func TestStoreCompact(t *testing.T) { end := make([]byte, 8) binary.BigEndian.PutUint64(end, uint64(4)) wact := []testutil.Action{ - {Name: "put", Params: []interface{}{metaBucketName, scheduledCompactKeyName, newTestRevBytes(revision{3, 0})}}, - {Name: "range", Params: []interface{}{keyBucketName, make([]byte, 17), end, int64(10000)}}, - {Name: "delete", Params: []interface{}{keyBucketName, key2}}, - {Name: "put", Params: []interface{}{metaBucketName, finishedCompactKeyName, newTestRevBytes(revision{3, 0})}}, + {Name: "put", Params: []any{metaBucketName, scheduledCompactKeyName, newTestRevBytes(revision{3, 0})}}, + {Name: "range", Params: []any{keyBucketName, make([]byte, 17), end, int64(10000)}}, + {Name: "delete", Params: []any{keyBucketName, key2}}, + {Name: "put", Params: []any{metaBucketName, finishedCompactKeyName, newTestRevBytes(revision{3, 0})}}, } if g := b.tx.Action(); !reflect.DeepEqual(g, wact) { t.Errorf("tx actions = %+v, want %+v", g, wact) } wact = []testutil.Action{ - {Name: "compact", Params: []interface{}{int64(3)}}, + {Name: "compact", Params: []any{int64(3)}}, } if g := fi.Action(); !reflect.DeepEqual(g, wact) { t.Errorf("index action = %+v, want %+v", g, wact) @@ -397,9 +397,9 @@ func TestStoreRestore(t *testing.T) { t.Errorf("current rev = %v, want 5", s.currentRev) } wact := []testutil.Action{ - {Name: "range", Params: []interface{}{metaBucketName, finishedCompactKeyName, []byte(nil), int64(0)}}, - {Name: "range", Params: []interface{}{metaBucketName, scheduledCompactKeyName, []byte(nil), int64(0)}}, - {Name: "range", Params: []interface{}{keyBucketName, newTestRevBytes(revision{1, 0}), newTestRevBytes(revision{math.MaxInt64, math.MaxInt64}), int64(restoreChunkKeys)}}, + {Name: "range", Params: []any{metaBucketName, finishedCompactKeyName, []byte(nil), int64(0)}}, + {Name: "range", Params: []any{metaBucketName, scheduledCompactKeyName, []byte(nil), int64(0)}}, + {Name: "range", Params: []any{keyBucketName, newTestRevBytes(revision{1, 0}), newTestRevBytes(revision{math.MaxInt64, math.MaxInt64}), int64(restoreChunkKeys)}}, } if g := b.tx.Action(); !reflect.DeepEqual(g, wact) { t.Errorf("tx actions = %+v, want %+v", g, wact) @@ -411,8 +411,8 @@ func TestStoreRestore(t *testing.T) { } ki := &keyIndex{key: []byte("foo"), modified: revision{5, 0}, generations: gens} wact = []testutil.Action{ - {Name: "keyIndex", Params: []interface{}{ki}}, - {Name: "insert", Params: []interface{}{ki}}, + {Name: "keyIndex", Params: []any{ki}}, + {Name: "insert", Params: []any{ki}}, } if g := fi.Action(); !reflect.DeepEqual(g, wact) { t.Errorf("index action = %+v, want %+v", g, wact) @@ -877,18 +877,18 @@ func (b *fakeBatchTx) RLock() {} func (b *fakeBatchTx) RUnlock() {} func (b *fakeBatchTx) UnsafeCreateBucket(name []byte) {} func (b *fakeBatchTx) UnsafePut(bucketName []byte, key []byte, value []byte) { - b.Recorder.Record(testutil.Action{Name: "put", Params: []interface{}{bucketName, key, value}}) + b.Recorder.Record(testutil.Action{Name: "put", Params: []any{bucketName, key, value}}) } func (b *fakeBatchTx) UnsafeSeqPut(bucketName []byte, key []byte, value []byte) { - b.Recorder.Record(testutil.Action{Name: "seqput", Params: []interface{}{bucketName, key, value}}) + b.Recorder.Record(testutil.Action{Name: "seqput", Params: []any{bucketName, key, value}}) } func (b *fakeBatchTx) UnsafeRange(bucketName []byte, key, endKey []byte, limit int64) (keys [][]byte, vals [][]byte) { - b.Recorder.Record(testutil.Action{Name: "range", Params: []interface{}{bucketName, key, endKey, limit}}) + b.Recorder.Record(testutil.Action{Name: "range", Params: []any{bucketName, key, endKey, limit}}) r := <-b.rangeRespc return r.keys, r.vals } func (b *fakeBatchTx) UnsafeDelete(bucketName []byte, key []byte) { - b.Recorder.Record(testutil.Action{Name: "delete", Params: []interface{}{bucketName, key}}) + b.Recorder.Record(testutil.Action{Name: "delete", Params: []any{bucketName, key}}) } func (b *fakeBatchTx) UnsafeForEach(bucketName []byte, visitor func(k, v []byte) error) error { return nil @@ -947,43 +947,43 @@ func (i *fakeIndex) CountRevisions(key, end []byte, atRev int64) int { } func (i *fakeIndex) Get(key []byte, atRev int64) (rev, created revision, ver int64, err error) { - i.Recorder.Record(testutil.Action{Name: "get", Params: []interface{}{key, atRev}}) + i.Recorder.Record(testutil.Action{Name: "get", Params: []any{key, atRev}}) r := <-i.indexGetRespc return r.rev, r.created, r.ver, r.err } func (i *fakeIndex) Range(key, end []byte, atRev int64) ([][]byte, []revision) { - i.Recorder.Record(testutil.Action{Name: "range", Params: []interface{}{key, end, atRev}}) + i.Recorder.Record(testutil.Action{Name: "range", Params: []any{key, end, atRev}}) r := <-i.indexRangeRespc return r.keys, r.revs } func (i *fakeIndex) Put(key []byte, rev revision) { - i.Recorder.Record(testutil.Action{Name: "put", Params: []interface{}{key, rev}}) + i.Recorder.Record(testutil.Action{Name: "put", Params: []any{key, rev}}) } func (i *fakeIndex) Tombstone(key []byte, rev revision) error { - i.Recorder.Record(testutil.Action{Name: "tombstone", Params: []interface{}{key, rev}}) + i.Recorder.Record(testutil.Action{Name: "tombstone", Params: []any{key, rev}}) return nil } func (i *fakeIndex) RangeSince(key, end []byte, rev int64) []revision { - i.Recorder.Record(testutil.Action{Name: "rangeEvents", Params: []interface{}{key, end, rev}}) + i.Recorder.Record(testutil.Action{Name: "rangeEvents", Params: []any{key, end, rev}}) r := <-i.indexRangeEventsRespc return r.revs } func (i *fakeIndex) Compact(rev int64) map[revision]struct{} { - i.Recorder.Record(testutil.Action{Name: "compact", Params: []interface{}{rev}}) + i.Recorder.Record(testutil.Action{Name: "compact", Params: []any{rev}}) return <-i.indexCompactRespc } func (i *fakeIndex) Keep(rev int64) map[revision]struct{} { - i.Recorder.Record(testutil.Action{Name: "keep", Params: []interface{}{rev}}) + i.Recorder.Record(testutil.Action{Name: "keep", Params: []any{rev}}) return <-i.indexCompactRespc } func (i *fakeIndex) Equal(b index) bool { return false } func (i *fakeIndex) Insert(ki *keyIndex) { - i.Recorder.Record(testutil.Action{Name: "insert", Params: []interface{}{ki}}) + i.Recorder.Record(testutil.Action{Name: "insert", Params: []any{ki}}) } func (i *fakeIndex) KeyIndex(ki *keyIndex) *keyIndex { - i.Recorder.Record(testutil.Action{Name: "keyIndex", Params: []interface{}{ki}}) + i.Recorder.Record(testutil.Action{Name: "keyIndex", Params: []any{ki}}) return nil } diff --git a/pkg/adt/interval_tree.go b/pkg/adt/interval_tree.go index 74a9aeb14..e71c9d957 100644 --- a/pkg/adt/interval_tree.go +++ b/pkg/adt/interval_tree.go @@ -176,7 +176,7 @@ func (x *intervalNode) visit(iv *Interval, sentinel *intervalNode, nv nodeVisito // IntervalValue represents a range tree node that contains a range and a value. type IntervalValue struct { Ivl Interval - Val interface{} + Val any } // IntervalTree represents a (mostly) textbook implementation of the @@ -184,7 +184,7 @@ type IntervalValue struct { // and chapter 14.3 interval tree with search supporting "stabbing queries". type IntervalTree interface { // Insert adds a node with the given interval into the tree. - Insert(ivl Interval, val interface{}) + Insert(ivl Interval, val any) // Delete removes the node with the given interval from the tree, returning // true if a node is in fact removed. Delete(ivl Interval) bool @@ -317,48 +317,47 @@ func (ivt *intervalTree) Delete(ivl Interval) bool { // "Introduction to Algorithms" (Cormen et al, 3rd ed.), chapter 13.4, p326 // -// 0. RB-DELETE-FIXUP(T, z) -// 1. -// 2. while x ≠ T.root and x.color == BLACK -// 3. if x == x.p.left -// 4. w = x.p.right -// 5. if w.color == RED -// 6. w.color = BLACK -// 7. x.p.color = RED -// 8. LEFT-ROTATE(T, x, p) -// 9. if w.left.color == BLACK and w.right.color == BLACK -// 10. w.color = RED -// 11. x = x.p -// 12. else if w.right.color == BLACK -// 13. w.left.color = BLACK -// 14. w.color = RED -// 15. RIGHT-ROTATE(T, w) -// 16. w = w.p.right -// 17. w.color = x.p.color -// 18. x.p.color = BLACK -// 19. LEFT-ROTATE(T, w.p) -// 20. x = T.root -// 21. else -// 22. w = x.p.left -// 23. if w.color == RED -// 24. w.color = BLACK -// 25. x.p.color = RED -// 26. RIGHT-ROTATE(T, x, p) -// 27. if w.right.color == BLACK and w.left.color == BLACK -// 28. w.color = RED -// 29. x = x.p -// 30. else if w.left.color == BLACK -// 31. w.right.color = BLACK -// 32. w.color = RED -// 33. LEFT-ROTATE(T, w) -// 34. w = w.p.left -// 35. w.color = x.p.color -// 36. x.p.color = BLACK -// 37. RIGHT-ROTATE(T, w.p) -// 38. x = T.root -// 39. -// 40. x.color = BLACK -// +// 0. RB-DELETE-FIXUP(T, z) +// 1. +// 2. while x ≠ T.root and x.color == BLACK +// 3. if x == x.p.left +// 4. w = x.p.right +// 5. if w.color == RED +// 6. w.color = BLACK +// 7. x.p.color = RED +// 8. LEFT-ROTATE(T, x, p) +// 9. if w.left.color == BLACK and w.right.color == BLACK +// 10. w.color = RED +// 11. x = x.p +// 12. else if w.right.color == BLACK +// 13. w.left.color = BLACK +// 14. w.color = RED +// 15. RIGHT-ROTATE(T, w) +// 16. w = w.p.right +// 17. w.color = x.p.color +// 18. x.p.color = BLACK +// 19. LEFT-ROTATE(T, w.p) +// 20. x = T.root +// 21. else +// 22. w = x.p.left +// 23. if w.color == RED +// 24. w.color = BLACK +// 25. x.p.color = RED +// 26. RIGHT-ROTATE(T, x, p) +// 27. if w.right.color == BLACK and w.left.color == BLACK +// 28. w.color = RED +// 29. x = x.p +// 30. else if w.left.color == BLACK +// 31. w.right.color = BLACK +// 32. w.color = RED +// 33. LEFT-ROTATE(T, w) +// 34. w = w.p.left +// 35. w.color = x.p.color +// 36. x.p.color = BLACK +// 37. RIGHT-ROTATE(T, w.p) +// 38. x = T.root +// 39. +// 40. x.color = BLACK func (ivt *intervalTree) deleteFixup(x *intervalNode) { for x != ivt.root && x.color(ivt.sentinel) == black { if x == x.parent.left { // line 3-20 @@ -424,7 +423,7 @@ func (ivt *intervalTree) deleteFixup(x *intervalNode) { } } -func (ivt *intervalTree) createIntervalNode(ivl Interval, val interface{}) *intervalNode { +func (ivt *intervalTree) createIntervalNode(ivl Interval, val any) *intervalNode { return &intervalNode{ iv: IntervalValue{ivl, val}, max: ivl.End, @@ -467,7 +466,7 @@ func (ivt *intervalTree) createIntervalNode(ivl Interval, val interface{}) *inte // 25. RB-INSERT-FIXUP(T, z) // Insert adds a node with the given interval into the tree. -func (ivt *intervalTree) Insert(ivl Interval, val interface{}) { +func (ivt *intervalTree) Insert(ivl Interval, val any) { y := ivt.sentinel z := ivt.createIntervalNode(ivl, val) x := ivt.root @@ -499,38 +498,37 @@ func (ivt *intervalTree) Insert(ivl Interval, val interface{}) { // "Introduction to Algorithms" (Cormen et al, 3rd ed.), chapter 13.3, p316 // -// 0. RB-INSERT-FIXUP(T, z) -// 1. -// 2. while z.p.color == RED -// 3. if z.p == z.p.p.left -// 4. y = z.p.p.right -// 5. if y.color == RED -// 6. z.p.color = BLACK -// 7. y.color = BLACK -// 8. z.p.p.color = RED -// 9. z = z.p.p -// 10. else if z == z.p.right -// 11. z = z.p -// 12. LEFT-ROTATE(T, z) -// 13. z.p.color = BLACK -// 14. z.p.p.color = RED -// 15. RIGHT-ROTATE(T, z.p.p) -// 16. else -// 17. y = z.p.p.left -// 18. if y.color == RED -// 19. z.p.color = BLACK -// 20. y.color = BLACK -// 21. z.p.p.color = RED -// 22. z = z.p.p -// 23. else if z == z.p.right -// 24. z = z.p -// 25. RIGHT-ROTATE(T, z) -// 26. z.p.color = BLACK -// 27. z.p.p.color = RED -// 28. LEFT-ROTATE(T, z.p.p) -// 29. -// 30. T.root.color = BLACK -// +// 0. RB-INSERT-FIXUP(T, z) +// 1. +// 2. while z.p.color == RED +// 3. if z.p == z.p.p.left +// 4. y = z.p.p.right +// 5. if y.color == RED +// 6. z.p.color = BLACK +// 7. y.color = BLACK +// 8. z.p.p.color = RED +// 9. z = z.p.p +// 10. else if z == z.p.right +// 11. z = z.p +// 12. LEFT-ROTATE(T, z) +// 13. z.p.color = BLACK +// 14. z.p.p.color = RED +// 15. RIGHT-ROTATE(T, z.p.p) +// 16. else +// 17. y = z.p.p.left +// 18. if y.color == RED +// 19. z.p.color = BLACK +// 20. y.color = BLACK +// 21. z.p.p.color = RED +// 22. z = z.p.p +// 23. else if z == z.p.right +// 24. z = z.p +// 25. RIGHT-ROTATE(T, z) +// 26. z.p.color = BLACK +// 27. z.p.p.color = RED +// 28. LEFT-ROTATE(T, z.p.p) +// 29. +// 30. T.root.color = BLACK func (ivt *intervalTree) insertFixup(z *intervalNode) { for z.parent.color(ivt.sentinel) == red { if z.parent == z.parent.parent.left { // line 3-15 @@ -578,26 +576,25 @@ func (ivt *intervalTree) insertFixup(z *intervalNode) { // // "Introduction to Algorithms" (Cormen et al, 3rd ed.), chapter 13.2, p313 // -// 0. LEFT-ROTATE(T, x) -// 1. -// 2. y = x.right -// 3. x.right = y.left -// 4. -// 5. if y.left ≠ T.nil -// 6. y.left.p = x -// 7. -// 8. y.p = x.p -// 9. -// 10. if x.p == T.nil -// 11. T.root = y -// 12. else if x == x.p.left -// 13. x.p.left = y -// 14. else -// 15. x.p.right = y -// 16. -// 17. y.left = x -// 18. x.p = y -// +// 0. LEFT-ROTATE(T, x) +// 1. +// 2. y = x.right +// 3. x.right = y.left +// 4. +// 5. if y.left ≠ T.nil +// 6. y.left.p = x +// 7. +// 8. y.p = x.p +// 9. +// 10. if x.p == T.nil +// 11. T.root = y +// 12. else if x == x.p.left +// 13. x.p.left = y +// 14. else +// 15. x.p.right = y +// 16. +// 17. y.left = x +// 18. x.p = y func (ivt *intervalTree) rotateLeft(x *intervalNode) { // rotateLeft x must have right child if x.right == ivt.sentinel { @@ -624,26 +621,25 @@ func (ivt *intervalTree) rotateLeft(x *intervalNode) { // rotateRight moves x so it is right of its left child // -// 0. RIGHT-ROTATE(T, x) -// 1. -// 2. y = x.left -// 3. x.left = y.right -// 4. -// 5. if y.right ≠ T.nil -// 6. y.right.p = x -// 7. -// 8. y.p = x.p -// 9. -// 10. if x.p == T.nil -// 11. T.root = y -// 12. else if x == x.p.right -// 13. x.p.right = y -// 14. else -// 15. x.p.left = y -// 16. -// 17. y.right = x -// 18. x.p = y -// +// 0. RIGHT-ROTATE(T, x) +// 1. +// 2. y = x.left +// 3. x.left = y.right +// 4. +// 5. if y.right ≠ T.nil +// 6. y.right.p = x +// 7. +// 8. y.p = x.p +// 9. +// 10. if x.p == T.nil +// 11. T.root = y +// 12. else if x == x.p.right +// 13. x.p.right = y +// 14. else +// 15. x.p.left = y +// 16. +// 17. y.right = x +// 18. x.p = y func (ivt *intervalTree) rotateRight(x *intervalNode) { // rotateRight x must have left child if x.left == ivt.sentinel { diff --git a/pkg/logutil/discard_logger.go b/pkg/logutil/discard_logger.go index 81b0a9d03..17e3bdfd5 100644 --- a/pkg/logutil/discard_logger.go +++ b/pkg/logutil/discard_logger.go @@ -28,18 +28,18 @@ func NewDiscardLogger() Logger { return &discardLogger{} } type discardLogger struct{} -func (l *discardLogger) Info(args ...interface{}) {} -func (l *discardLogger) Infoln(args ...interface{}) {} -func (l *discardLogger) Infof(format string, args ...interface{}) {} -func (l *discardLogger) Warning(args ...interface{}) {} -func (l *discardLogger) Warningln(args ...interface{}) {} -func (l *discardLogger) Warningf(format string, args ...interface{}) {} -func (l *discardLogger) Error(args ...interface{}) {} -func (l *discardLogger) Errorln(args ...interface{}) {} -func (l *discardLogger) Errorf(format string, args ...interface{}) {} -func (l *discardLogger) Fatal(args ...interface{}) { log.Fatal(args...) } -func (l *discardLogger) Fatalln(args ...interface{}) { log.Fatalln(args...) } -func (l *discardLogger) Fatalf(format string, args ...interface{}) { log.Fatalf(format, args...) } +func (l *discardLogger) Info(args ...any) {} +func (l *discardLogger) Infoln(args ...any) {} +func (l *discardLogger) Infof(format string, args ...any) {} +func (l *discardLogger) Warning(args ...any) {} +func (l *discardLogger) Warningln(args ...any) {} +func (l *discardLogger) Warningf(format string, args ...any) {} +func (l *discardLogger) Error(args ...any) {} +func (l *discardLogger) Errorln(args ...any) {} +func (l *discardLogger) Errorf(format string, args ...any) {} +func (l *discardLogger) Fatal(args ...any) { log.Fatal(args...) } +func (l *discardLogger) Fatalln(args ...any) { log.Fatalln(args...) } +func (l *discardLogger) Fatalf(format string, args ...any) { log.Fatalf(format, args...) } func (l *discardLogger) V(lvl int) bool { return false } diff --git a/pkg/logutil/logger.go b/pkg/logutil/logger.go index e7da80eff..08bb26365 100644 --- a/pkg/logutil/logger.go +++ b/pkg/logutil/logger.go @@ -33,29 +33,28 @@ var _ Logger = &defaultLogger{} // // For example: // -// var defaultLogger Logger -// g := grpclog.NewLoggerV2WithVerbosity(os.Stderr, os.Stderr, os.Stderr, 4) -// defaultLogger = NewLogger(g) -// +// var defaultLogger Logger +// g := grpclog.NewLoggerV2WithVerbosity(os.Stderr, os.Stderr, os.Stderr, 4) +// defaultLogger = NewLogger(g) func NewLogger(g grpclog.LoggerV2) Logger { return &defaultLogger{g: g} } type defaultLogger struct { g grpclog.LoggerV2 } -func (l *defaultLogger) Info(args ...interface{}) { l.g.Info(args...) } -func (l *defaultLogger) Infoln(args ...interface{}) { l.g.Info(args...) } -func (l *defaultLogger) Infof(format string, args ...interface{}) { l.g.Infof(format, args...) } -func (l *defaultLogger) Warning(args ...interface{}) { l.g.Warning(args...) } -func (l *defaultLogger) Warningln(args ...interface{}) { l.g.Warning(args...) } -func (l *defaultLogger) Warningf(format string, args ...interface{}) { l.g.Warningf(format, args...) } -func (l *defaultLogger) Error(args ...interface{}) { l.g.Error(args...) } -func (l *defaultLogger) Errorln(args ...interface{}) { l.g.Error(args...) } -func (l *defaultLogger) Errorf(format string, args ...interface{}) { l.g.Errorf(format, args...) } -func (l *defaultLogger) Fatal(args ...interface{}) { l.g.Fatal(args...) } -func (l *defaultLogger) Fatalln(args ...interface{}) { l.g.Fatal(args...) } -func (l *defaultLogger) Fatalf(format string, args ...interface{}) { l.g.Fatalf(format, args...) } -func (l *defaultLogger) V(lvl int) bool { return l.g.V(lvl) } +func (l *defaultLogger) Info(args ...any) { l.g.Info(args...) } +func (l *defaultLogger) Infoln(args ...any) { l.g.Info(args...) } +func (l *defaultLogger) Infof(format string, args ...any) { l.g.Infof(format, args...) } +func (l *defaultLogger) Warning(args ...any) { l.g.Warning(args...) } +func (l *defaultLogger) Warningln(args ...any) { l.g.Warning(args...) } +func (l *defaultLogger) Warningf(format string, args ...any) { l.g.Warningf(format, args...) } +func (l *defaultLogger) Error(args ...any) { l.g.Error(args...) } +func (l *defaultLogger) Errorln(args ...any) { l.g.Error(args...) } +func (l *defaultLogger) Errorf(format string, args ...any) { l.g.Errorf(format, args...) } +func (l *defaultLogger) Fatal(args ...any) { l.g.Fatal(args...) } +func (l *defaultLogger) Fatalln(args ...any) { l.g.Fatal(args...) } +func (l *defaultLogger) Fatalf(format string, args ...any) { l.g.Fatalf(format, args...) } +func (l *defaultLogger) V(lvl int) bool { return l.g.V(lvl) } func (l *defaultLogger) Lvl(lvl int) grpclog.LoggerV2 { if l.g.V(lvl) { return l diff --git a/pkg/logutil/zap_grpc.go b/pkg/logutil/zap_grpc.go index 3f48d813d..63e16d742 100644 --- a/pkg/logutil/zap_grpc.go +++ b/pkg/logutil/zap_grpc.go @@ -45,60 +45,60 @@ type zapGRPCLogger struct { sugar *zap.SugaredLogger } -func (zl *zapGRPCLogger) Info(args ...interface{}) { +func (zl *zapGRPCLogger) Info(args ...any) { if !zl.lg.Core().Enabled(zapcore.DebugLevel) { return } zl.sugar.Info(args...) } -func (zl *zapGRPCLogger) Infoln(args ...interface{}) { +func (zl *zapGRPCLogger) Infoln(args ...any) { if !zl.lg.Core().Enabled(zapcore.DebugLevel) { return } zl.sugar.Info(args...) } -func (zl *zapGRPCLogger) Infof(format string, args ...interface{}) { +func (zl *zapGRPCLogger) Infof(format string, args ...any) { if !zl.lg.Core().Enabled(zapcore.DebugLevel) { return } zl.sugar.Infof(format, args...) } -func (zl *zapGRPCLogger) Warning(args ...interface{}) { +func (zl *zapGRPCLogger) Warning(args ...any) { zl.sugar.Warn(args...) } -func (zl *zapGRPCLogger) Warningln(args ...interface{}) { +func (zl *zapGRPCLogger) Warningln(args ...any) { zl.sugar.Warn(args...) } -func (zl *zapGRPCLogger) Warningf(format string, args ...interface{}) { +func (zl *zapGRPCLogger) Warningf(format string, args ...any) { zl.sugar.Warnf(format, args...) } -func (zl *zapGRPCLogger) Error(args ...interface{}) { +func (zl *zapGRPCLogger) Error(args ...any) { zl.sugar.Error(args...) } -func (zl *zapGRPCLogger) Errorln(args ...interface{}) { +func (zl *zapGRPCLogger) Errorln(args ...any) { zl.sugar.Error(args...) } -func (zl *zapGRPCLogger) Errorf(format string, args ...interface{}) { +func (zl *zapGRPCLogger) Errorf(format string, args ...any) { zl.sugar.Errorf(format, args...) } -func (zl *zapGRPCLogger) Fatal(args ...interface{}) { +func (zl *zapGRPCLogger) Fatal(args ...any) { zl.sugar.Fatal(args...) } -func (zl *zapGRPCLogger) Fatalln(args ...interface{}) { +func (zl *zapGRPCLogger) Fatalln(args ...any) { zl.sugar.Fatal(args...) } -func (zl *zapGRPCLogger) Fatalf(format string, args ...interface{}) { +func (zl *zapGRPCLogger) Fatalf(format string, args ...any) { zl.sugar.Fatalf(format, args...) } diff --git a/pkg/logutil/zap_raft.go b/pkg/logutil/zap_raft.go index f0772a17c..ce4c17cc2 100644 --- a/pkg/logutil/zap_raft.go +++ b/pkg/logutil/zap_raft.go @@ -53,50 +53,50 @@ type zapRaftLogger struct { sugar *zap.SugaredLogger } -func (zl *zapRaftLogger) Debug(args ...interface{}) { +func (zl *zapRaftLogger) Debug(args ...any) { zl.sugar.Debug(args...) } -func (zl *zapRaftLogger) Debugf(format string, args ...interface{}) { +func (zl *zapRaftLogger) Debugf(format string, args ...any) { zl.sugar.Debugf(format, args...) } -func (zl *zapRaftLogger) Error(args ...interface{}) { +func (zl *zapRaftLogger) Error(args ...any) { zl.sugar.Error(args...) } -func (zl *zapRaftLogger) Errorf(format string, args ...interface{}) { +func (zl *zapRaftLogger) Errorf(format string, args ...any) { zl.sugar.Errorf(format, args...) } -func (zl *zapRaftLogger) Info(args ...interface{}) { +func (zl *zapRaftLogger) Info(args ...any) { zl.sugar.Info(args...) } -func (zl *zapRaftLogger) Infof(format string, args ...interface{}) { +func (zl *zapRaftLogger) Infof(format string, args ...any) { zl.sugar.Infof(format, args...) } -func (zl *zapRaftLogger) Warning(args ...interface{}) { +func (zl *zapRaftLogger) Warning(args ...any) { zl.sugar.Warn(args...) } -func (zl *zapRaftLogger) Warningf(format string, args ...interface{}) { +func (zl *zapRaftLogger) Warningf(format string, args ...any) { zl.sugar.Warnf(format, args...) } -func (zl *zapRaftLogger) Fatal(args ...interface{}) { +func (zl *zapRaftLogger) Fatal(args ...any) { zl.sugar.Fatal(args...) } -func (zl *zapRaftLogger) Fatalf(format string, args ...interface{}) { +func (zl *zapRaftLogger) Fatalf(format string, args ...any) { zl.sugar.Fatalf(format, args...) } -func (zl *zapRaftLogger) Panic(args ...interface{}) { +func (zl *zapRaftLogger) Panic(args ...any) { zl.sugar.Panic(args...) } -func (zl *zapRaftLogger) Panicf(format string, args ...interface{}) { +func (zl *zapRaftLogger) Panicf(format string, args ...any) { zl.sugar.Panicf(format, args...) } diff --git a/pkg/mock/mockstore/store_recorder.go b/pkg/mock/mockstore/store_recorder.go index 386b266bf..7916c7853 100644 --- a/pkg/mock/mockstore/store_recorder.go +++ b/pkg/mock/mockstore/store_recorder.go @@ -50,49 +50,49 @@ func (s *storeRecorder) Index() uint64 { return 0 } func (s *storeRecorder) Get(path string, recursive, sorted bool) (*v2store.Event, error) { s.Record(testutil.Action{ Name: "Get", - Params: []interface{}{path, recursive, sorted}, + Params: []any{path, recursive, sorted}, }) return &v2store.Event{}, nil } func (s *storeRecorder) Set(path string, dir bool, val string, expireOpts v2store.TTLOptionSet) (*v2store.Event, error) { s.Record(testutil.Action{ Name: "Set", - Params: []interface{}{path, dir, val, expireOpts}, + Params: []any{path, dir, val, expireOpts}, }) return &v2store.Event{}, nil } func (s *storeRecorder) Update(path, val string, expireOpts v2store.TTLOptionSet) (*v2store.Event, error) { s.Record(testutil.Action{ Name: "Update", - Params: []interface{}{path, val, expireOpts}, + Params: []any{path, val, expireOpts}, }) return &v2store.Event{}, nil } func (s *storeRecorder) Create(path string, dir bool, val string, uniq bool, expireOpts v2store.TTLOptionSet) (*v2store.Event, error) { s.Record(testutil.Action{ Name: "Create", - Params: []interface{}{path, dir, val, uniq, expireOpts}, + Params: []any{path, dir, val, uniq, expireOpts}, }) return &v2store.Event{}, nil } func (s *storeRecorder) CompareAndSwap(path, prevVal string, prevIdx uint64, val string, expireOpts v2store.TTLOptionSet) (*v2store.Event, error) { s.Record(testutil.Action{ Name: "CompareAndSwap", - Params: []interface{}{path, prevVal, prevIdx, val, expireOpts}, + Params: []any{path, prevVal, prevIdx, val, expireOpts}, }) return &v2store.Event{}, nil } func (s *storeRecorder) Delete(path string, dir, recursive bool) (*v2store.Event, error) { s.Record(testutil.Action{ Name: "Delete", - Params: []interface{}{path, dir, recursive}, + Params: []any{path, dir, recursive}, }) return &v2store.Event{}, nil } func (s *storeRecorder) CompareAndDelete(path, prevVal string, prevIdx uint64) (*v2store.Event, error) { s.Record(testutil.Action{ Name: "CompareAndDelete", - Params: []interface{}{path, prevVal, prevIdx}, + Params: []any{path, prevVal, prevIdx}, }) return &v2store.Event{}, nil } @@ -123,7 +123,7 @@ func (s *storeRecorder) JsonStats() []byte { return nil } func (s *storeRecorder) DeleteExpiredKeys(cutoff time.Time) { s.Record(testutil.Action{ Name: "DeleteExpiredKeys", - Params: []interface{}{cutoff}, + Params: []any{cutoff}, }) } diff --git a/pkg/mock/mockwait/wait_recorder.go b/pkg/mock/mockwait/wait_recorder.go index f6bd657d4..db31e6022 100644 --- a/pkg/mock/mockwait/wait_recorder.go +++ b/pkg/mock/mockwait/wait_recorder.go @@ -34,11 +34,11 @@ func NewRecorder() *WaitRecorder { } func NewNop() wait.Wait { return NewRecorder() } -func (w *waitRecorder) Register(id uint64) <-chan interface{} { +func (w *waitRecorder) Register(id uint64) <-chan any { w.Record(testutil.Action{Name: "Register"}) return nil } -func (w *waitRecorder) Trigger(id uint64, x interface{}) { +func (w *waitRecorder) Trigger(id uint64, x any) { w.Record(testutil.Action{Name: "Trigger"}) } diff --git a/pkg/testutil/assert.go b/pkg/testutil/assert.go index 9cf03457d..f3a999fe7 100644 --- a/pkg/testutil/assert.go +++ b/pkg/testutil/assert.go @@ -20,7 +20,7 @@ import ( "testing" ) -func AssertEqual(t *testing.T, e, a interface{}, msg ...string) { +func AssertEqual(t *testing.T, e, a any, msg ...string) { if (e == nil || a == nil) && (isNil(e) && isNil(a)) { return } @@ -35,11 +35,11 @@ func AssertEqual(t *testing.T, e, a interface{}, msg ...string) { FatalStack(t, s) } -func AssertNil(t *testing.T, v interface{}) { +func AssertNil(t *testing.T, v any) { AssertEqual(t, nil, v) } -func AssertNotNil(t *testing.T, v interface{}) { +func AssertNotNil(t *testing.T, v any) { if v == nil { t.Fatalf("expected non-nil, got %+v", v) } @@ -53,7 +53,7 @@ func AssertFalse(t *testing.T, v bool, msg ...string) { AssertEqual(t, false, v, msg...) } -func isNil(v interface{}) bool { +func isNil(v any) bool { if v == nil { return true } diff --git a/pkg/testutil/recorder.go b/pkg/testutil/recorder.go index 3722f9de1..ec61eeab9 100644 --- a/pkg/testutil/recorder.go +++ b/pkg/testutil/recorder.go @@ -23,7 +23,7 @@ import ( type Action struct { Name string - Params []interface{} + Params []any } type Recorder interface { diff --git a/pkg/traceutil/trace.go b/pkg/traceutil/trace.go index cbe2cfbf0..fa135b2e9 100644 --- a/pkg/traceutil/trace.go +++ b/pkg/traceutil/trace.go @@ -33,7 +33,7 @@ const ( // Field is a kv pair to record additional details of the trace. type Field struct { Key string - Value interface{} + Value any } func (f *Field) format() string { diff --git a/pkg/wait/wait.go b/pkg/wait/wait.go index 9b1df419e..e7c1db60c 100644 --- a/pkg/wait/wait.go +++ b/pkg/wait/wait.go @@ -27,28 +27,28 @@ type Wait interface { // Register waits returns a chan that waits on the given ID. // The chan will be triggered when Trigger is called with // the same ID. - Register(id uint64) <-chan interface{} + Register(id uint64) <-chan any // Trigger triggers the waiting chans with the given ID. - Trigger(id uint64, x interface{}) + Trigger(id uint64, x any) IsRegistered(id uint64) bool } type list struct { l sync.RWMutex - m map[uint64]chan interface{} + m map[uint64]chan any } // New creates a Wait. func New() Wait { - return &list{m: make(map[uint64]chan interface{})} + return &list{m: make(map[uint64]chan any)} } -func (w *list) Register(id uint64) <-chan interface{} { +func (w *list) Register(id uint64) <-chan any { w.l.Lock() defer w.l.Unlock() ch := w.m[id] if ch == nil { - ch = make(chan interface{}, 1) + ch = make(chan any, 1) w.m[id] = ch } else { log.Panicf("dup id %x", id) @@ -56,7 +56,7 @@ func (w *list) Register(id uint64) <-chan interface{} { return ch } -func (w *list) Trigger(id uint64, x interface{}) { +func (w *list) Trigger(id uint64, x any) { w.l.Lock() ch := w.m[id] delete(w.m, id) @@ -75,17 +75,17 @@ func (w *list) IsRegistered(id uint64) bool { } type waitWithResponse struct { - ch <-chan interface{} + ch <-chan any } -func NewWithResponse(ch <-chan interface{}) Wait { +func NewWithResponse(ch <-chan any) Wait { return &waitWithResponse{ch: ch} } -func (w *waitWithResponse) Register(id uint64) <-chan interface{} { +func (w *waitWithResponse) Register(id uint64) <-chan any { return w.ch } -func (w *waitWithResponse) Trigger(id uint64, x interface{}) {} +func (w *waitWithResponse) Trigger(id uint64, x any) {} func (w *waitWithResponse) IsRegistered(id uint64) bool { panic("waitWithResponse.IsRegistered() shouldn't be called") } diff --git a/proxy/grpcproxy/adapter/chan_stream.go b/proxy/grpcproxy/adapter/chan_stream.go index 1af514b1f..eaf4309c9 100644 --- a/proxy/grpcproxy/adapter/chan_stream.go +++ b/proxy/grpcproxy/adapter/chan_stream.go @@ -96,15 +96,15 @@ func (cs *chanClientStream) CloseSend() error { // chanStream implements grpc.Stream using channels type chanStream struct { - recvc <-chan interface{} - sendc chan<- interface{} + recvc <-chan any + sendc chan<- any ctx context.Context cancel context.CancelFunc } func (s *chanStream) Context() context.Context { return s.ctx } -func (s *chanStream) SendMsg(m interface{}) error { +func (s *chanStream) SendMsg(m any) error { select { case s.sendc <- m: if err, ok := m.(error); ok { @@ -116,8 +116,8 @@ func (s *chanStream) SendMsg(m interface{}) error { return s.ctx.Err() } -func (s *chanStream) RecvMsg(m interface{}) error { - v := m.(*interface{}) +func (s *chanStream) RecvMsg(m any) error { + v := m.(*any) for { select { case msg, ok := <-s.recvc: @@ -141,7 +141,7 @@ func (s *chanStream) RecvMsg(m interface{}) error { func newPipeStream(ctx context.Context, ssHandler func(chanServerStream) error) chanClientStream { // ch1 is buffered so server can send error on close - ch1, ch2 := make(chan interface{}, 1), make(chan interface{}) + ch1, ch2 := make(chan any, 1), make(chan any) headerc, trailerc := make(chan metadata.MD, 1), make(chan metadata.MD, 1) cctx, ccancel := context.WithCancel(ctx) diff --git a/proxy/grpcproxy/adapter/election_client_adapter.go b/proxy/grpcproxy/adapter/election_client_adapter.go index 06ebcc9ef..5ef6c6e48 100644 --- a/proxy/grpcproxy/adapter/election_client_adapter.go +++ b/proxy/grpcproxy/adapter/election_client_adapter.go @@ -61,7 +61,7 @@ func (s *es2ecClientStream) Send(rr *v3electionpb.LeaderRequest) error { return s.SendMsg(rr) } func (s *es2ecClientStream) Recv() (*v3electionpb.LeaderResponse, error) { - var v interface{} + var v any if err := s.RecvMsg(&v); err != nil { return nil, err } @@ -72,7 +72,7 @@ func (s *es2ecServerStream) Send(rr *v3electionpb.LeaderResponse) error { return s.SendMsg(rr) } func (s *es2ecServerStream) Recv() (*v3electionpb.LeaderRequest, error) { - var v interface{} + var v any if err := s.RecvMsg(&v); err != nil { return nil, err } diff --git a/proxy/grpcproxy/adapter/lease_client_adapter.go b/proxy/grpcproxy/adapter/lease_client_adapter.go index e2c9518c5..1681f240f 100644 --- a/proxy/grpcproxy/adapter/lease_client_adapter.go +++ b/proxy/grpcproxy/adapter/lease_client_adapter.go @@ -63,7 +63,7 @@ func (s *ls2lcClientStream) Send(rr *pb.LeaseKeepAliveRequest) error { return s.SendMsg(rr) } func (s *ls2lcClientStream) Recv() (*pb.LeaseKeepAliveResponse, error) { - var v interface{} + var v any if err := s.RecvMsg(&v); err != nil { return nil, err } @@ -74,7 +74,7 @@ func (s *ls2lcServerStream) Send(rr *pb.LeaseKeepAliveResponse) error { return s.SendMsg(rr) } func (s *ls2lcServerStream) Recv() (*pb.LeaseKeepAliveRequest, error) { - var v interface{} + var v any if err := s.RecvMsg(&v); err != nil { return nil, err } diff --git a/proxy/grpcproxy/adapter/maintenance_client_adapter.go b/proxy/grpcproxy/adapter/maintenance_client_adapter.go index ca5b0c86c..8eaac96ed 100644 --- a/proxy/grpcproxy/adapter/maintenance_client_adapter.go +++ b/proxy/grpcproxy/adapter/maintenance_client_adapter.go @@ -73,7 +73,7 @@ func (s *ss2scClientStream) Send(rr *pb.SnapshotRequest) error { return s.SendMsg(rr) } func (s *ss2scClientStream) Recv() (*pb.SnapshotResponse, error) { - var v interface{} + var v any if err := s.RecvMsg(&v); err != nil { return nil, err } @@ -84,7 +84,7 @@ func (s *ss2scServerStream) Send(rr *pb.SnapshotResponse) error { return s.SendMsg(rr) } func (s *ss2scServerStream) Recv() (*pb.SnapshotRequest, error) { - var v interface{} + var v any if err := s.RecvMsg(&v); err != nil { return nil, err } diff --git a/proxy/grpcproxy/adapter/watch_client_adapter.go b/proxy/grpcproxy/adapter/watch_client_adapter.go index 5bede2594..08a447ad9 100644 --- a/proxy/grpcproxy/adapter/watch_client_adapter.go +++ b/proxy/grpcproxy/adapter/watch_client_adapter.go @@ -47,7 +47,7 @@ func (s *ws2wcClientStream) Send(wr *pb.WatchRequest) error { return s.SendMsg(wr) } func (s *ws2wcClientStream) Recv() (*pb.WatchResponse, error) { - var v interface{} + var v any if err := s.RecvMsg(&v); err != nil { return nil, err } @@ -58,7 +58,7 @@ func (s *ws2wcServerStream) Send(wr *pb.WatchResponse) error { return s.SendMsg(wr) } func (s *ws2wcServerStream) Recv() (*pb.WatchRequest, error) { - var v interface{} + var v any if err := s.RecvMsg(&v); err != nil { return nil, err } diff --git a/proxy/grpcproxy/util.go b/proxy/grpcproxy/util.go index f33479c24..0524f59e9 100644 --- a/proxy/grpcproxy/util.go +++ b/proxy/grpcproxy/util.go @@ -56,7 +56,7 @@ func (cred *proxyTokenCredential) GetRequestMetadata(ctx context.Context, s ...s }, nil } -func AuthUnaryClientInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { +func AuthUnaryClientInterceptor(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { token := getAuthTokenFromClient(ctx) if token != "" { tokenCred := &proxyTokenCredential{token} diff --git a/raft/logger.go b/raft/logger.go index 6d8962965..307bf75be 100644 --- a/raft/logger.go +++ b/raft/logger.go @@ -23,23 +23,23 @@ import ( ) type Logger interface { - Debug(v ...interface{}) - Debugf(format string, v ...interface{}) + Debug(v ...any) + Debugf(format string, v ...any) - Error(v ...interface{}) - Errorf(format string, v ...interface{}) + Error(v ...any) + Errorf(format string, v ...any) - Info(v ...interface{}) - Infof(format string, v ...interface{}) + Info(v ...any) + Infof(format string, v ...any) - Warning(v ...interface{}) - Warningf(format string, v ...interface{}) + Warning(v ...any) + Warningf(format string, v ...any) - Fatal(v ...interface{}) - Fatalf(format string, v ...interface{}) + Fatal(v ...any) + Fatalf(format string, v ...any) - Panic(v ...interface{}) - Panicf(format string, v ...interface{}) + Panic(v ...any) + Panicf(format string, v ...any) } func SetLogger(l Logger) { @@ -73,57 +73,57 @@ func (l *DefaultLogger) EnableDebug() { l.debug = true } -func (l *DefaultLogger) Debug(v ...interface{}) { +func (l *DefaultLogger) Debug(v ...any) { if l.debug { l.Output(calldepth, header("DEBUG", fmt.Sprint(v...))) } } -func (l *DefaultLogger) Debugf(format string, v ...interface{}) { +func (l *DefaultLogger) Debugf(format string, v ...any) { if l.debug { l.Output(calldepth, header("DEBUG", fmt.Sprintf(format, v...))) } } -func (l *DefaultLogger) Info(v ...interface{}) { +func (l *DefaultLogger) Info(v ...any) { l.Output(calldepth, header("INFO", fmt.Sprint(v...))) } -func (l *DefaultLogger) Infof(format string, v ...interface{}) { +func (l *DefaultLogger) Infof(format string, v ...any) { l.Output(calldepth, header("INFO", fmt.Sprintf(format, v...))) } -func (l *DefaultLogger) Error(v ...interface{}) { +func (l *DefaultLogger) Error(v ...any) { l.Output(calldepth, header("ERROR", fmt.Sprint(v...))) } -func (l *DefaultLogger) Errorf(format string, v ...interface{}) { +func (l *DefaultLogger) Errorf(format string, v ...any) { l.Output(calldepth, header("ERROR", fmt.Sprintf(format, v...))) } -func (l *DefaultLogger) Warning(v ...interface{}) { +func (l *DefaultLogger) Warning(v ...any) { l.Output(calldepth, header("WARN", fmt.Sprint(v...))) } -func (l *DefaultLogger) Warningf(format string, v ...interface{}) { +func (l *DefaultLogger) Warningf(format string, v ...any) { l.Output(calldepth, header("WARN", fmt.Sprintf(format, v...))) } -func (l *DefaultLogger) Fatal(v ...interface{}) { +func (l *DefaultLogger) Fatal(v ...any) { l.Output(calldepth, header("FATAL", fmt.Sprint(v...))) os.Exit(1) } -func (l *DefaultLogger) Fatalf(format string, v ...interface{}) { +func (l *DefaultLogger) Fatalf(format string, v ...any) { l.Output(calldepth, header("FATAL", fmt.Sprintf(format, v...))) os.Exit(1) } -func (l *DefaultLogger) Panic(v ...interface{}) { +func (l *DefaultLogger) Panic(v ...any) { l.Logger.Panic(v...) } -func (l *DefaultLogger) Panicf(format string, v ...interface{}) { +func (l *DefaultLogger) Panicf(format string, v ...any) { l.Logger.Panicf(format, v...) } diff --git a/raft/rafttest/interaction_env_logger.go b/raft/rafttest/interaction_env_logger.go index fcd5ba236..736af2019 100644 --- a/raft/rafttest/interaction_env_logger.go +++ b/raft/rafttest/interaction_env_logger.go @@ -32,7 +32,7 @@ type RedirectLogger struct { var _ raft.Logger = (*RedirectLogger)(nil) -func (l *RedirectLogger) printf(lvl int, format string, args ...interface{}) { +func (l *RedirectLogger) printf(lvl int, format string, args ...any) { if l.Lvl <= lvl { fmt.Fprint(l, lvlNames[lvl], " ") fmt.Fprintf(l, format, args...) @@ -41,58 +41,58 @@ func (l *RedirectLogger) printf(lvl int, format string, args ...interface{}) { } } } -func (l *RedirectLogger) print(lvl int, args ...interface{}) { +func (l *RedirectLogger) print(lvl int, args ...any) { if l.Lvl <= lvl { fmt.Fprint(l, lvlNames[lvl], " ") fmt.Fprintln(l, args...) } } -func (l *RedirectLogger) Debug(v ...interface{}) { +func (l *RedirectLogger) Debug(v ...any) { l.print(0, v...) } -func (l *RedirectLogger) Debugf(format string, v ...interface{}) { +func (l *RedirectLogger) Debugf(format string, v ...any) { l.printf(0, format, v...) } -func (l *RedirectLogger) Info(v ...interface{}) { +func (l *RedirectLogger) Info(v ...any) { l.print(1, v...) } -func (l *RedirectLogger) Infof(format string, v ...interface{}) { +func (l *RedirectLogger) Infof(format string, v ...any) { l.printf(1, format, v...) } -func (l *RedirectLogger) Warning(v ...interface{}) { +func (l *RedirectLogger) Warning(v ...any) { l.print(2, v...) } -func (l *RedirectLogger) Warningf(format string, v ...interface{}) { +func (l *RedirectLogger) Warningf(format string, v ...any) { l.printf(2, format, v...) } -func (l *RedirectLogger) Error(v ...interface{}) { +func (l *RedirectLogger) Error(v ...any) { l.print(3, v...) } -func (l *RedirectLogger) Errorf(format string, v ...interface{}) { +func (l *RedirectLogger) Errorf(format string, v ...any) { l.printf(3, format, v...) } -func (l *RedirectLogger) Fatal(v ...interface{}) { +func (l *RedirectLogger) Fatal(v ...any) { l.print(4, v...) } -func (l *RedirectLogger) Fatalf(format string, v ...interface{}) { +func (l *RedirectLogger) Fatalf(format string, v ...any) { l.printf(4, format, v...) } -func (l *RedirectLogger) Panic(v ...interface{}) { +func (l *RedirectLogger) Panic(v ...any) { l.print(4, v...) } -func (l *RedirectLogger) Panicf(format string, v ...interface{}) { +func (l *RedirectLogger) Panicf(format string, v ...any) { l.printf(4, format, v...) } diff --git a/tests/e2e/util.go b/tests/e2e/util.go index de73e511a..7487a8bd7 100644 --- a/tests/e2e/util.go +++ b/tests/e2e/util.go @@ -83,7 +83,7 @@ func randomLeaseID() int64 { return rand.New(rand.NewSource(time.Now().UnixNano())).Int63() } -func dataMarshal(data interface{}) (d string, e error) { +func dataMarshal(data any) (d string, e error) { m, err := json.Marshal(data) if err != nil { return "", err diff --git a/tests/e2e/v3_curl_test.go b/tests/e2e/v3_curl_test.go index a19cb68d4..11da51057 100644 --- a/tests/e2e/v3_curl_test.go +++ b/tests/e2e/v3_curl_test.go @@ -250,7 +250,7 @@ func testV3CurlAuth(cx ctlCtx) { cURLRes, err := proc.ExpectFunc(lineFunc) testutil.AssertNil(cx.t, err) - authRes := make(map[string]interface{}) + authRes := make(map[string]any) testutil.AssertNil(cx.t, json.Unmarshal([]byte(cURLRes), &authRes)) token, ok := authRes[rpctypes.TokenFieldNameGRPC].(string) diff --git a/vendor/github.com/cockroachdb/datadriven/datadriven.go b/vendor/github.com/cockroachdb/datadriven/datadriven.go index bcc0a6019..1f12b01d2 100644 --- a/vendor/github.com/cockroachdb/datadriven/datadriven.go +++ b/vendor/github.com/cockroachdb/datadriven/datadriven.go @@ -41,24 +41,24 @@ var ( // testing framework. By convention, test files are typically located in a // sub-directory called "testdata". Each test file has the following format: // -// [,...] [arg | arg=val | arg=(val1, val2, ...)]... -// -// ---- -// +// [,...] [arg | arg=val | arg=(val1, val2, ...)]... +// +// ---- +// // // The command input can contain blank lines. However, by default, the expected // results cannot contain blank lines. This alternate syntax allows the use of // blank lines: // -// [,...] [arg | arg=val | arg=(val1, val2, ...)]... -// -// ---- -// ---- -// +// [,...] [arg | arg=val | arg=(val1, val2, ...)]... +// +// ---- +// ---- +// // -// -// ---- -// ---- +// +// ---- +// ---- // // To execute data-driven tests, pass the path of the test file as well as a // function which can interpret and execute whatever commands are present in @@ -161,27 +161,26 @@ func runTestInternal( // // This can be used in conjunction with RunTest. For example: // -// datadriven.Walk(t, path, func (t *testing.T, path string) { -// // initialize per-test state -// datadriven.RunTest(t, path, func (d *datadriven.TestData) { -// // ... -// } -// } +// datadriven.Walk(t, path, func (t *testing.T, path string) { +// // initialize per-test state +// datadriven.RunTest(t, path, func (d *datadriven.TestData) { +// // ... +// } +// } // -// Files: -// testdata/typing -// testdata/logprops/scan -// testdata/logprops/select +// Files: +// testdata/typing +// testdata/logprops/scan +// testdata/logprops/select // -// If path is "testdata/typing", the function is called once and no subtests -// care created. +// If path is "testdata/typing", the function is called once and no subtests +// care created. // -// If path is "testdata/logprops", the function is called two times, in -// separate subtests /scan, /select. -// -// If path is "testdata", the function is called three times, in subtest -// hierarchy /typing, /logprops/scan, /logprops/select. +// If path is "testdata/logprops", the function is called two times, in +// separate subtests /scan, /select. // +// If path is "testdata", the function is called three times, in subtest +// hierarchy /typing, /logprops/scan, /logprops/select. func Walk(t *testing.T, path string, f func(t *testing.T, path string)) { finfo, err := os.Stat(path) if err != nil { @@ -221,7 +220,7 @@ type TestData struct { // destinations does not match that of the arguments, or a destination can not // be populated from its matching value, a fatal error results. // -// For example, for a TestData originating from +// # For example, for a TestData originating from // // cmd arg1=50 arg2=yoruba arg3=(50, 50, 50) // @@ -232,7 +231,7 @@ type TestData struct { // td.ScanArgs(t, "arg1", &i1) // td.ScanArgs(t, "arg2", &s) // td.ScanArgs(t, "arg3", &i2, &i3, &i4) -func (td *TestData) ScanArgs(t *testing.T, key string, dests ...interface{}) { +func (td *TestData) ScanArgs(t *testing.T, key string, dests ...any) { t.Helper() var arg CmdArg for i := range td.CmdArgs { @@ -256,9 +255,9 @@ func (td *TestData) ScanArgs(t *testing.T, key string, dests ...interface{}) { // CmdArg contains information about an argument on the directive line. An // argument is specified in one of the following forms: -// - argument -// - argument=value -// - argument=(values, ...) +// - argument +// - argument=value +// - argument=(values, ...) type CmdArg struct { Key string Vals []string @@ -278,7 +277,7 @@ func (arg CmdArg) String() string { } // Scan attempts to parse the value at index i into the dest. -func (arg CmdArg) Scan(t *testing.T, i int, dest interface{}) { +func (arg CmdArg) Scan(t *testing.T, i int, dest any) { if i < 0 || i >= len(arg.Vals) { t.Fatalf("cannot scan index %d of key %s", i, arg.Key) } @@ -311,7 +310,7 @@ func (arg CmdArg) Scan(t *testing.T, i int, dest interface{}) { // Fatalf wraps a fatal testing error with test file position information, so // that it's easy to locate the source of the error. -func (td TestData) Fatalf(tb testing.TB, format string, args ...interface{}) { +func (td TestData) Fatalf(tb testing.TB, format string, args ...any) { tb.Helper() tb.Fatalf("%s: %s", td.Pos, fmt.Sprintf(format, args...)) } diff --git a/vendor/github.com/coreos/go-semver/semver/semver.go b/vendor/github.com/coreos/go-semver/semver/semver.go index 110fc23e1..16c0d75e3 100644 --- a/vendor/github.com/coreos/go-semver/semver/semver.go +++ b/vendor/github.com/coreos/go-semver/semver/semver.go @@ -110,7 +110,7 @@ func (v Version) String() string { return buffer.String() } -func (v *Version) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (v *Version) UnmarshalYAML(unmarshal func(any) error) error { var data string if err := unmarshal(&data); err != nil { return err diff --git a/vendor/github.com/coreos/go-systemd/v22/journal/journal.go b/vendor/github.com/coreos/go-systemd/v22/journal/journal.go index a0f4837a0..9176c5bf7 100644 --- a/vendor/github.com/coreos/go-systemd/v22/journal/journal.go +++ b/vendor/github.com/coreos/go-systemd/v22/journal/journal.go @@ -137,7 +137,7 @@ func Send(message string, priority Priority, vars map[string]string) error { } // Print prints a message to the local systemd journal using Send(). -func Print(priority Priority, format string, a ...interface{}) error { +func Print(priority Priority, format string, a ...any) error { return Send(fmt.Sprintf(format, a...), priority, nil) } diff --git a/vendor/github.com/dgrijalva/jwt-go/ecdsa.go b/vendor/github.com/dgrijalva/jwt-go/ecdsa.go index f97738124..8d3c4aa2e 100644 --- a/vendor/github.com/dgrijalva/jwt-go/ecdsa.go +++ b/vendor/github.com/dgrijalva/jwt-go/ecdsa.go @@ -55,7 +55,7 @@ func (m *SigningMethodECDSA) Alg() string { // Implements the Verify method from SigningMethod // For this verify method, key must be an ecdsa.PublicKey struct -func (m *SigningMethodECDSA) Verify(signingString, signature string, key interface{}) error { +func (m *SigningMethodECDSA) Verify(signingString, signature string, key any) error { var err error // Decode the signature @@ -97,7 +97,7 @@ func (m *SigningMethodECDSA) Verify(signingString, signature string, key interfa // Implements the Sign method from SigningMethod // For this signing method, key must be an ecdsa.PrivateKey struct -func (m *SigningMethodECDSA) Sign(signingString string, key interface{}) (string, error) { +func (m *SigningMethodECDSA) Sign(signingString string, key any) (string, error) { // Get the key var ecdsaKey *ecdsa.PrivateKey switch k := key.(type) { diff --git a/vendor/github.com/dgrijalva/jwt-go/ecdsa_utils.go b/vendor/github.com/dgrijalva/jwt-go/ecdsa_utils.go index d19624b72..7c3100076 100644 --- a/vendor/github.com/dgrijalva/jwt-go/ecdsa_utils.go +++ b/vendor/github.com/dgrijalva/jwt-go/ecdsa_utils.go @@ -23,7 +23,7 @@ func ParseECPrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error) { } // Parse the key - var parsedKey interface{} + var parsedKey any if parsedKey, err = x509.ParseECPrivateKey(block.Bytes); err != nil { return nil, err } @@ -48,7 +48,7 @@ func ParseECPublicKeyFromPEM(key []byte) (*ecdsa.PublicKey, error) { } // Parse the key - var parsedKey interface{} + var parsedKey any if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil { if cert, err := x509.ParseCertificate(block.Bytes); err == nil { parsedKey = cert.PublicKey diff --git a/vendor/github.com/dgrijalva/jwt-go/hmac.go b/vendor/github.com/dgrijalva/jwt-go/hmac.go index addbe5d40..ef0a92c27 100644 --- a/vendor/github.com/dgrijalva/jwt-go/hmac.go +++ b/vendor/github.com/dgrijalva/jwt-go/hmac.go @@ -46,7 +46,7 @@ func (m *SigningMethodHMAC) Alg() string { } // Verify the signature of HSXXX tokens. Returns nil if the signature is valid. -func (m *SigningMethodHMAC) Verify(signingString, signature string, key interface{}) error { +func (m *SigningMethodHMAC) Verify(signingString, signature string, key any) error { // Verify the key is the right type keyBytes, ok := key.([]byte) if !ok { @@ -79,7 +79,7 @@ func (m *SigningMethodHMAC) Verify(signingString, signature string, key interfac // Implements the Sign method from SigningMethod for this signing method. // Key must be []byte -func (m *SigningMethodHMAC) Sign(signingString string, key interface{}) (string, error) { +func (m *SigningMethodHMAC) Sign(signingString string, key any) (string, error) { if keyBytes, ok := key.([]byte); ok { if !m.Hash.Available() { return "", ErrHashUnavailable diff --git a/vendor/github.com/dgrijalva/jwt-go/map_claims.go b/vendor/github.com/dgrijalva/jwt-go/map_claims.go index 291213c46..720395362 100644 --- a/vendor/github.com/dgrijalva/jwt-go/map_claims.go +++ b/vendor/github.com/dgrijalva/jwt-go/map_claims.go @@ -8,7 +8,7 @@ import ( // Claims type that uses the map[string]interface{} for JSON decoding // This is the default claims type if you don't supply one -type MapClaims map[string]interface{} +type MapClaims map[string]any // Compares the aud claim against cmp. // If required is false, this method will return true if the value matches or is unset diff --git a/vendor/github.com/dgrijalva/jwt-go/none.go b/vendor/github.com/dgrijalva/jwt-go/none.go index f04d189d0..f6028ff6c 100644 --- a/vendor/github.com/dgrijalva/jwt-go/none.go +++ b/vendor/github.com/dgrijalva/jwt-go/none.go @@ -25,7 +25,7 @@ func (m *signingMethodNone) Alg() string { } // Only allow 'none' alg type if UnsafeAllowNoneSignatureType is specified as the key -func (m *signingMethodNone) Verify(signingString, signature string, key interface{}) (err error) { +func (m *signingMethodNone) Verify(signingString, signature string, key any) (err error) { // Key must be UnsafeAllowNoneSignatureType to prevent accidentally // accepting 'none' signing method if _, ok := key.(unsafeNoneMagicConstant); !ok { @@ -44,7 +44,7 @@ func (m *signingMethodNone) Verify(signingString, signature string, key interfac } // Only allow 'none' signing if UnsafeAllowNoneSignatureType is specified as the key -func (m *signingMethodNone) Sign(signingString string, key interface{}) (string, error) { +func (m *signingMethodNone) Sign(signingString string, key any) (string, error) { if _, ok := key.(unsafeNoneMagicConstant); ok { return "", nil } diff --git a/vendor/github.com/dgrijalva/jwt-go/parser.go b/vendor/github.com/dgrijalva/jwt-go/parser.go index d6901d9ad..e1f5f1cf3 100644 --- a/vendor/github.com/dgrijalva/jwt-go/parser.go +++ b/vendor/github.com/dgrijalva/jwt-go/parser.go @@ -43,7 +43,7 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf } // Lookup key - var key interface{} + var key any if keyFunc == nil { // keyFunc was not provided. short circuiting validation return token, NewValidationError("no Keyfunc was provided.", ValidationErrorUnverifiable) diff --git a/vendor/github.com/dgrijalva/jwt-go/rsa.go b/vendor/github.com/dgrijalva/jwt-go/rsa.go index e4caf1ca4..ab9ac2730 100644 --- a/vendor/github.com/dgrijalva/jwt-go/rsa.go +++ b/vendor/github.com/dgrijalva/jwt-go/rsa.go @@ -46,7 +46,7 @@ func (m *SigningMethodRSA) Alg() string { // Implements the Verify method from SigningMethod // For this signing method, must be an *rsa.PublicKey structure. -func (m *SigningMethodRSA) Verify(signingString, signature string, key interface{}) error { +func (m *SigningMethodRSA) Verify(signingString, signature string, key any) error { var err error // Decode the signature @@ -75,7 +75,7 @@ func (m *SigningMethodRSA) Verify(signingString, signature string, key interface // Implements the Sign method from SigningMethod // For this signing method, must be an *rsa.PrivateKey structure. -func (m *SigningMethodRSA) Sign(signingString string, key interface{}) (string, error) { +func (m *SigningMethodRSA) Sign(signingString string, key any) (string, error) { var rsaKey *rsa.PrivateKey var ok bool diff --git a/vendor/github.com/dgrijalva/jwt-go/rsa_pss.go b/vendor/github.com/dgrijalva/jwt-go/rsa_pss.go index 10ee9db8a..92962f78f 100644 --- a/vendor/github.com/dgrijalva/jwt-go/rsa_pss.go +++ b/vendor/github.com/dgrijalva/jwt-go/rsa_pss.go @@ -1,3 +1,4 @@ +//go:build go1.4 // +build go1.4 package jwt @@ -70,7 +71,7 @@ func init() { // Implements the Verify method from SigningMethod // For this verify method, key must be an rsa.PublicKey struct -func (m *SigningMethodRSAPSS) Verify(signingString, signature string, key interface{}) error { +func (m *SigningMethodRSAPSS) Verify(signingString, signature string, key any) error { var err error // Decode the signature @@ -99,7 +100,7 @@ func (m *SigningMethodRSAPSS) Verify(signingString, signature string, key interf // Implements the Sign method from SigningMethod // For this signing method, key must be an rsa.PrivateKey struct -func (m *SigningMethodRSAPSS) Sign(signingString string, key interface{}) (string, error) { +func (m *SigningMethodRSAPSS) Sign(signingString string, key any) (string, error) { var rsaKey *rsa.PrivateKey switch k := key.(type) { diff --git a/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go b/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go index a5ababf95..ed132fe0c 100644 --- a/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go +++ b/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go @@ -23,7 +23,7 @@ func ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error) { return nil, ErrKeyMustBePEMEncoded } - var parsedKey interface{} + var parsedKey any if parsedKey, err = x509.ParsePKCS1PrivateKey(block.Bytes); err != nil { if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil { return nil, err @@ -49,7 +49,7 @@ func ParseRSAPrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.Pr return nil, ErrKeyMustBePEMEncoded } - var parsedKey interface{} + var parsedKey any var blockDecrypted []byte if blockDecrypted, err = x509.DecryptPEMBlock(block, []byte(password)); err != nil { @@ -82,7 +82,7 @@ func ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error) { } // Parse the key - var parsedKey interface{} + var parsedKey any if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil { if cert, err := x509.ParseCertificate(block.Bytes); err == nil { parsedKey = cert.PublicKey diff --git a/vendor/github.com/dgrijalva/jwt-go/signing_method.go b/vendor/github.com/dgrijalva/jwt-go/signing_method.go index ed1f212b2..1128f7b74 100644 --- a/vendor/github.com/dgrijalva/jwt-go/signing_method.go +++ b/vendor/github.com/dgrijalva/jwt-go/signing_method.go @@ -9,9 +9,9 @@ var signingMethodLock = new(sync.RWMutex) // Implement SigningMethod to add new methods for signing or verifying tokens. type SigningMethod interface { - Verify(signingString, signature string, key interface{}) error // Returns nil if signature is valid - Sign(signingString string, key interface{}) (string, error) // Returns encoded signature or error - Alg() string // returns the alg identifier for this method (example: 'HS256') + Verify(signingString, signature string, key any) error // Returns nil if signature is valid + Sign(signingString string, key any) (string, error) // Returns encoded signature or error + Alg() string // returns the alg identifier for this method (example: 'HS256') } // Register the "alg" name and a factory function for signing method. diff --git a/vendor/github.com/dgrijalva/jwt-go/token.go b/vendor/github.com/dgrijalva/jwt-go/token.go index d637e0867..08fa3b0a1 100644 --- a/vendor/github.com/dgrijalva/jwt-go/token.go +++ b/vendor/github.com/dgrijalva/jwt-go/token.go @@ -16,17 +16,17 @@ var TimeFunc = time.Now // the key for verification. The function receives the parsed, // but unverified Token. This allows you to use properties in the // Header of the token (such as `kid`) to identify which key to use. -type Keyfunc func(*Token) (interface{}, error) +type Keyfunc func(*Token) (any, error) // A JWT Token. Different fields will be used depending on whether you're // creating or parsing/verifying a token. type Token struct { - Raw string // The raw token. Populated when you Parse a token - Method SigningMethod // The signing method used or to be used - Header map[string]interface{} // The first segment of the token - Claims Claims // The second segment of the token - Signature string // The third segment of the token. Populated when you Parse a token - Valid bool // Is the token valid? Populated when you Parse/Verify a token + Raw string // The raw token. Populated when you Parse a token + Method SigningMethod // The signing method used or to be used + Header map[string]any // The first segment of the token + Claims Claims // The second segment of the token + Signature string // The third segment of the token. Populated when you Parse a token + Valid bool // Is the token valid? Populated when you Parse/Verify a token } // Create a new Token. Takes a signing method @@ -36,7 +36,7 @@ func New(method SigningMethod) *Token { func NewWithClaims(method SigningMethod, claims Claims) *Token { return &Token{ - Header: map[string]interface{}{ + Header: map[string]any{ "typ": "JWT", "alg": method.Alg(), }, @@ -46,7 +46,7 @@ func NewWithClaims(method SigningMethod, claims Claims) *Token { } // Get the complete, signed token -func (t *Token) SignedString(key interface{}) (string, error) { +func (t *Token) SignedString(key any) (string, error) { var sig, sstr string var err error if sstr, err = t.SigningString(); err != nil { diff --git a/vendor/github.com/dustin/go-humanize/times.go b/vendor/github.com/dustin/go-humanize/times.go index dd3fbf5ef..0ed70b01d 100644 --- a/vendor/github.com/dustin/go-humanize/times.go +++ b/vendor/github.com/dustin/go-humanize/times.go @@ -98,7 +98,7 @@ func CustomRelTime(a, b time.Time, albl, blbl string, magnitudes []RelTimeMagnit n = len(magnitudes) - 1 } mag := magnitudes[n] - args := []interface{}{} + args := []any{} escaped := false for _, ch := range mag.Format { if escaped { diff --git a/vendor/github.com/gogo/protobuf/proto/deprecated.go b/vendor/github.com/gogo/protobuf/proto/deprecated.go index 35b882c09..2731db59a 100644 --- a/vendor/github.com/gogo/protobuf/proto/deprecated.go +++ b/vendor/github.com/gogo/protobuf/proto/deprecated.go @@ -40,22 +40,22 @@ type Stats struct{ Emalloc, Dmalloc, Encode, Decode, Chit, Cmiss, Size uint64 } func GetStats() Stats { return Stats{} } // Deprecated: do not use. -func MarshalMessageSet(interface{}) ([]byte, error) { +func MarshalMessageSet(any) ([]byte, error) { return nil, errors.New("proto: not implemented") } // Deprecated: do not use. -func UnmarshalMessageSet([]byte, interface{}) error { +func UnmarshalMessageSet([]byte, any) error { return errors.New("proto: not implemented") } // Deprecated: do not use. -func MarshalMessageSetJSON(interface{}) ([]byte, error) { +func MarshalMessageSetJSON(any) ([]byte, error) { return nil, errors.New("proto: not implemented") } // Deprecated: do not use. -func UnmarshalMessageSetJSON([]byte, interface{}) error { +func UnmarshalMessageSetJSON([]byte, any) error { return errors.New("proto: not implemented") } diff --git a/vendor/github.com/gogo/protobuf/proto/extensions.go b/vendor/github.com/gogo/protobuf/proto/extensions.go index 686bd2a09..5e14db859 100644 --- a/vendor/github.com/gogo/protobuf/proto/extensions.go +++ b/vendor/github.com/gogo/protobuf/proto/extensions.go @@ -92,7 +92,7 @@ func (n notLocker) Unlock() {} // extendable returns the extendableProto interface for the given generated proto message. // If the proto message has the old extension format, it returns a wrapper that implements // the extendableProto interface. -func extendable(p interface{}) (extendableProto, error) { +func extendable(p any) (extendableProto, error) { switch p := p.(type) { case extendableProto: if isNilPtr(p) { @@ -114,7 +114,7 @@ func extendable(p interface{}) (extendableProto, error) { var errNotExtendable = errors.New("proto: not an extendable proto.Message") -func isNilPtr(x interface{}) bool { +func isNilPtr(x any) bool { v := reflect.ValueOf(x) return v.Kind() == reflect.Ptr && v.IsNil() } @@ -164,12 +164,12 @@ func (e *XXX_InternalExtensions) extensionsRead() (map[int32]Extension, sync.Loc // ExtensionDesc represents an extension specification. // Used in generated code from the protocol compiler. type ExtensionDesc struct { - ExtendedType Message // nil pointer to the type that is being extended - ExtensionType interface{} // nil pointer to the extension type - Field int32 // field number - Name string // fully-qualified name of extension, for text formatting - Tag string // protobuf tag style - Filename string // name of the file in which the extension is defined + ExtendedType Message // nil pointer to the type that is being extended + ExtensionType any // nil pointer to the extension type + Field int32 // field number + Name string // fully-qualified name of extension, for text formatting + Tag string // protobuf tag style + Filename string // name of the file in which the extension is defined } func (ed *ExtensionDesc) repeated() bool { @@ -188,7 +188,7 @@ type Extension struct { // accessed using GetExtension (or GetExtensions) desc and value // will be set. desc *ExtensionDesc - value interface{} + value any enc []byte } @@ -220,7 +220,7 @@ func isExtensionField(pb extendableProto, field int32) bool { // checkExtensionTypes checks that the given extension is valid for pb. func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error { - var pbi interface{} = pb + var pbi any = pb // Check the extended type. if ea, ok := pbi.(extensionAdapter); ok { pbi = ea.extendableProtoV1 @@ -342,7 +342,7 @@ func clearExtension(pb Message, fieldNum int32) { // // If the descriptor is not type complete (i.e., ExtensionDesc.ExtensionType is nil), // then GetExtension returns the raw encoded bytes of the field extension. -func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) { +func GetExtension(pb Message, extension *ExtensionDesc) (any, error) { if epb, doki := pb.(extensionsBytes); doki { ext := epb.GetExtensions() return decodeExtensionFromBytes(extension, *ext) @@ -405,7 +405,7 @@ func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) { // defaultExtensionValue returns the default value for extension. // If no default for an extension is defined ErrMissingExtension is returned. -func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) { +func defaultExtensionValue(extension *ExtensionDesc) (any, error) { if extension.ExtensionType == nil { // incomplete descriptor, so no default return nil, ErrMissingExtension @@ -444,7 +444,7 @@ func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) { } // decodeExtension decodes an extension encoded in b. -func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { +func decodeExtension(b []byte, extension *ExtensionDesc) (any, error) { t := reflect.TypeOf(extension.ExtensionType) unmarshal := typeUnmarshaler(t, extension.Tag) @@ -475,12 +475,12 @@ func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { // GetExtensions returns a slice of the extensions present in pb that are also listed in es. // The returned slice has the same length as es; missing extensions will appear as nil elements. -func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) { +func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []any, err error) { epb, err := extendable(pb) if err != nil { return nil, err } - extensions = make([]interface{}, len(es)) + extensions = make([]any, len(es)) for i, e := range es { extensions[i], err = GetExtension(epb, e) if err == ErrMissingExtension { @@ -525,7 +525,7 @@ func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) { } // SetExtension sets the specified extension of pb to the specified value. -func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error { +func SetExtension(pb Message, extension *ExtensionDesc, value any) error { if epb, ok := pb.(extensionsBytes); ok { newb, err := encodeExtension(extension, value) if err != nil { diff --git a/vendor/github.com/gogo/protobuf/proto/extensions_gogo.go b/vendor/github.com/gogo/protobuf/proto/extensions_gogo.go index 53ebd8cca..18feaa07a 100644 --- a/vendor/github.com/gogo/protobuf/proto/extensions_gogo.go +++ b/vendor/github.com/gogo/protobuf/proto/extensions_gogo.go @@ -249,7 +249,7 @@ func AppendExtension(e Message, tag int32, buf []byte) { } } -func encodeExtension(extension *ExtensionDesc, value interface{}) ([]byte, error) { +func encodeExtension(extension *ExtensionDesc, value any) ([]byte, error) { u := getMarshalInfo(reflect.TypeOf(extension.ExtendedType)) ei := u.getExtElemInfo(extension) v := value @@ -259,7 +259,7 @@ func encodeExtension(extension *ExtensionDesc, value interface{}) ([]byte, error return ei.marshaler(buf, p, ei.wiretag, false) } -func decodeExtensionFromBytes(extension *ExtensionDesc, buf []byte) (interface{}, error) { +func decodeExtensionFromBytes(extension *ExtensionDesc, buf []byte) (any, error) { o := 0 for o < len(buf) { tag, n := DecodeVarint((buf)[o:]) @@ -305,7 +305,7 @@ func (this Extension) GoString() string { return fmt.Sprintf("proto.NewExtension(%#v)", this.enc) } -func SetUnsafeExtension(pb Message, fieldNum int32, value interface{}) error { +func SetUnsafeExtension(pb Message, fieldNum int32, value any) error { typ := reflect.TypeOf(pb).Elem() ext, ok := extensionMaps[typ] if !ok { @@ -318,7 +318,7 @@ func SetUnsafeExtension(pb Message, fieldNum int32, value interface{}) error { return SetExtension(pb, desc, value) } -func GetUnsafeExtension(pb Message, fieldNum int32) (interface{}, error) { +func GetUnsafeExtension(pb Message, fieldNum int32) (any, error) { typ := reflect.TypeOf(pb).Elem() ext, ok := extensionMaps[typ] if !ok { diff --git a/vendor/github.com/gogo/protobuf/proto/lib.go b/vendor/github.com/gogo/protobuf/proto/lib.go index d17f80209..ee43828c8 100644 --- a/vendor/github.com/gogo/protobuf/proto/lib.go +++ b/vendor/github.com/gogo/protobuf/proto/lib.go @@ -39,35 +39,35 @@ for a protocol buffer variable v: - Names are turned from camel_case to CamelCase for export. - There are no methods on v to set fields; just treat - them as structure fields. + them as structure fields. - There are getters that return a field's value if set, - and return the field's default value if unset. - The getters work even if the receiver is a nil message. + and return the field's default value if unset. + The getters work even if the receiver is a nil message. - The zero value for a struct is its correct initialization state. - All desired fields must be set before marshaling. + All desired fields must be set before marshaling. - A Reset() method will restore a protobuf struct to its zero state. - Non-repeated fields are pointers to the values; nil means unset. - That is, optional or required field int32 f becomes F *int32. + That is, optional or required field int32 f becomes F *int32. - Repeated fields are slices. - Helper functions are available to aid the setting of fields. - msg.Foo = proto.String("hello") // set field + msg.Foo = proto.String("hello") // set field - Constants are defined to hold the default values of all fields that - have them. They have the form Default_StructName_FieldName. - Because the getter methods handle defaulted values, - direct use of these constants should be rare. + have them. They have the form Default_StructName_FieldName. + Because the getter methods handle defaulted values, + direct use of these constants should be rare. - Enums are given type names and maps from names to values. - Enum values are prefixed by the enclosing message's name, or by the - enum's type name if it is a top-level enum. Enum types have a String - method, and a Enum method to assist in message construction. + Enum values are prefixed by the enclosing message's name, or by the + enum's type name if it is a top-level enum. Enum types have a String + method, and a Enum method to assist in message construction. - Nested messages, groups and enums have type names prefixed with the name of - the surrounding message type. + the surrounding message type. - Extensions are given descriptor names that start with E_, - followed by an underscore-delimited list of the nested messages - that contain it (if any) followed by the CamelCased name of the - extension field itself. HasExtension, ClearExtension, GetExtension - and SetExtension are functions for manipulating extensions. + followed by an underscore-delimited list of the nested messages + that contain it (if any) followed by the CamelCased name of the + extension field itself. HasExtension, ClearExtension, GetExtension + and SetExtension are functions for manipulating extensions. - Oneof field sets are given a single field in their message, - with distinguished wrapper types for each possible field value. + with distinguished wrapper types for each possible field value. - Marshal and Unmarshal are functions to encode and decode the wire format. When the .proto file specifies `syntax="proto3"`, there are some differences: @@ -764,7 +764,7 @@ type defaultMessage struct { type scalarField struct { index int // struct field index kind reflect.Kind // element type (the T in *T or []T) - value interface{} // the proto-declared default value, or nil + value any // the proto-declared default value, or nil } // t is a struct type. diff --git a/vendor/github.com/gogo/protobuf/proto/message_set.go b/vendor/github.com/gogo/protobuf/proto/message_set.go index f48a75676..88ff3b435 100644 --- a/vendor/github.com/gogo/protobuf/proto/message_set.go +++ b/vendor/github.com/gogo/protobuf/proto/message_set.go @@ -141,7 +141,7 @@ func skipVarint(buf []byte) []byte { // unmarshalMessageSet decodes the extension map encoded in buf in the message set wire format. // It is called by Unmarshal methods on protocol buffer messages with the message_set_wire_format option. -func unmarshalMessageSet(buf []byte, exts interface{}) error { +func unmarshalMessageSet(buf []byte, exts any) error { var m map[int32]Extension switch exts := exts.(type) { case *XXX_InternalExtensions: diff --git a/vendor/github.com/gogo/protobuf/proto/pointer_reflect.go b/vendor/github.com/gogo/protobuf/proto/pointer_reflect.go index b6cad9083..f1c8ce200 100644 --- a/vendor/github.com/gogo/protobuf/proto/pointer_reflect.go +++ b/vendor/github.com/gogo/protobuf/proto/pointer_reflect.go @@ -29,6 +29,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +//go:build purego || appengine || js // +build purego appengine js // This file contains an implementation of proto field accesses using package reflect. @@ -79,7 +80,7 @@ func toPointer(i *Message) pointer { // toAddrPointer converts an interface to a pointer that points to // the interface data. -func toAddrPointer(i *interface{}, isptr bool) pointer { +func toAddrPointer(i *any, isptr bool) pointer { v := reflect.ValueOf(*i) u := reflect.New(v.Type()) u.Elem().Set(v) diff --git a/vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go b/vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go index d55a335d9..3a3f8c798 100644 --- a/vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go +++ b/vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go @@ -29,6 +29,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +//go:build !purego && !appengine && !js // +build !purego,!appengine,!js // This file contains the implementation of the proto field accesses using package unsafe. @@ -85,7 +86,7 @@ func toPointer(i *Message) pointer { // toAddrPointer converts an interface to a pointer that points to // the interface data. -func toAddrPointer(i *interface{}, isptr bool) pointer { +func toAddrPointer(i *any, isptr bool) pointer { // Super-tricky - read or get the address of data word of interface value. if isptr { // The interface is of pointer type, thus it is a direct interface. diff --git a/vendor/github.com/gogo/protobuf/proto/properties.go b/vendor/github.com/gogo/protobuf/proto/properties.go index c9e5fa020..20e86d679 100644 --- a/vendor/github.com/gogo/protobuf/proto/properties.go +++ b/vendor/github.com/gogo/protobuf/proto/properties.go @@ -442,10 +442,10 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { sort.Sort(prop) type oneofMessage interface { - XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) + XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []any) } if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); isOneofMessage && ok { - var oots []interface{} + var oots []any _, _, _, oots = om.XXX_OneofFuncs() // Interpret oneof metadata. @@ -550,7 +550,7 @@ func RegisterType(x Message, name string) { // RegisterMapType is called from generated code and maps from the fully qualified // proto name to the native map type of the proto map definition. -func RegisterMapType(x interface{}, name string) { +func RegisterMapType(x any, name string) { if reflect.TypeOf(x).Kind() != reflect.Map { panic(fmt.Sprintf("RegisterMapType(%T, %q); want map", x, name)) } diff --git a/vendor/github.com/gogo/protobuf/proto/table_marshal.go b/vendor/github.com/gogo/protobuf/proto/table_marshal.go index 9b1538d05..c8a47d5f7 100644 --- a/vendor/github.com/gogo/protobuf/proto/table_marshal.go +++ b/vendor/github.com/gogo/protobuf/proto/table_marshal.go @@ -147,7 +147,7 @@ func (a *InternalMessageInfo) Marshal(b []byte, msg Message, deterministic bool) return u.marshal(b, ptr, deterministic) } -func getMessageMarshalInfo(msg interface{}, a *InternalMessageInfo) *marshalInfo { +func getMessageMarshalInfo(msg any, a *InternalMessageInfo) *marshalInfo { // u := a.marshal, but atomically. // We use an atomic here to ensure memory consistency. u := atomicLoadMarshalInfo(&a.marshal) @@ -387,7 +387,7 @@ func (u *marshalInfo) computeMarshalInfo() { } // get oneof implementers - var oneofImplementers []interface{} + var oneofImplementers []any // gogo: isOneofMessage is needed for embedded oneof messages, without a marshaler and unmarshaler if m, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); ok && isOneofMessage { _, _, _, oneofImplementers = m.XXX_OneofFuncs() @@ -489,7 +489,7 @@ func (fi *marshalFieldInfo) computeMarshalFieldInfo(f *reflect.StructField) { fi.setMarshaler(f, tags) } -func (fi *marshalFieldInfo) computeOneofFieldInfo(f *reflect.StructField, oneofImplementers []interface{}) { +func (fi *marshalFieldInfo) computeOneofFieldInfo(f *reflect.StructField, oneofImplementers []any) { fi.field = toField(f) fi.wiretag = math.MaxInt32 // Use a large tag number, make oneofs sorted at the end. This tag will not appear on the wire. fi.isPointer = true @@ -520,7 +520,7 @@ func (fi *marshalFieldInfo) computeOneofFieldInfo(f *reflect.StructField, oneofI } type oneofMessage interface { - XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) + XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []any) } // wiretype returns the wire encoding of the type. diff --git a/vendor/github.com/gogo/protobuf/proto/table_unmarshal.go b/vendor/github.com/gogo/protobuf/proto/table_unmarshal.go index bb2622f28..fca497c0c 100644 --- a/vendor/github.com/gogo/protobuf/proto/table_unmarshal.go +++ b/vendor/github.com/gogo/protobuf/proto/table_unmarshal.go @@ -2000,12 +2000,14 @@ func makeUnmarshalMap(f *reflect.StructField) unmarshaler { // makeUnmarshalOneof makes an unmarshaler for oneof fields. // for: -// message Msg { -// oneof F { -// int64 X = 1; -// float64 Y = 2; -// } -// } +// +// message Msg { +// oneof F { +// int64 X = 1; +// float64 Y = 2; +// } +// } +// // typ is the type of the concrete entry for a oneof case (e.g. Msg_X). // ityp is the interface type of the oneof field (e.g. isMsg_F). // unmarshal is the unmarshaler for the base type of the oneof case (e.g. int64). diff --git a/vendor/github.com/gogo/protobuf/proto/text.go b/vendor/github.com/gogo/protobuf/proto/text.go index 0407ba85d..37900c507 100644 --- a/vendor/github.com/gogo/protobuf/proto/text.go +++ b/vendor/github.com/gogo/protobuf/proto/text.go @@ -816,7 +816,7 @@ func (tm *TextMarshaler) writeExtensions(w *textWriter, pv reflect.Value) error return nil } -func (tm *TextMarshaler) writeExtension(w *textWriter, name string, pb interface{}) error { +func (tm *TextMarshaler) writeExtension(w *textWriter, name string, pb any) error { if _, err := fmt.Fprintf(w, "[%s]:", name); err != nil { return err } diff --git a/vendor/github.com/gogo/protobuf/proto/text_parser.go b/vendor/github.com/gogo/protobuf/proto/text_parser.go index 1ce0be2fa..0ef439a43 100644 --- a/vendor/github.com/gogo/protobuf/proto/text_parser.go +++ b/vendor/github.com/gogo/protobuf/proto/text_parser.go @@ -98,7 +98,7 @@ func newTextParser(s string) *textParser { return p } -func (p *textParser) errorf(format string, a ...interface{}) *ParseError { +func (p *textParser) errorf(format string, a ...any) *ParseError { pe := &ParseError{fmt.Sprintf(format, a...), p.cur.line, p.cur.offset} p.cur.err = pe p.done = true diff --git a/vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor/descriptor_gostring.gen.go b/vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor/descriptor_gostring.gen.go index 165b2110d..35258c15b 100644 --- a/vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor/descriptor_gostring.gen.go +++ b/vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor/descriptor_gostring.gen.go @@ -724,7 +724,7 @@ func (this *GeneratedCodeInfo_Annotation) GoString() string { s = append(s, "}") return strings.Join(s, "") } -func valueToGoStringDescriptor(v interface{}, typ string) string { +func valueToGoStringDescriptor(v any, typ string) string { rv := reflect.ValueOf(v) if rv.IsNil() { return "nil" diff --git a/vendor/github.com/golang/groupcache/lru/lru.go b/vendor/github.com/golang/groupcache/lru/lru.go index cdfe2991f..9b19f5daf 100644 --- a/vendor/github.com/golang/groupcache/lru/lru.go +++ b/vendor/github.com/golang/groupcache/lru/lru.go @@ -27,18 +27,18 @@ type Cache struct { // OnEvicted optionally specificies a callback function to be // executed when an entry is purged from the cache. - OnEvicted func(key Key, value interface{}) + OnEvicted func(key Key, value any) ll *list.List - cache map[interface{}]*list.Element + cache map[any]*list.Element } // A Key may be any value that is comparable. See http://golang.org/ref/spec#Comparison_operators -type Key interface{} +type Key any type entry struct { key Key - value interface{} + value any } // New creates a new Cache. @@ -48,14 +48,14 @@ func New(maxEntries int) *Cache { return &Cache{ MaxEntries: maxEntries, ll: list.New(), - cache: make(map[interface{}]*list.Element), + cache: make(map[any]*list.Element), } } // Add adds a value to the cache. -func (c *Cache) Add(key Key, value interface{}) { +func (c *Cache) Add(key Key, value any) { if c.cache == nil { - c.cache = make(map[interface{}]*list.Element) + c.cache = make(map[any]*list.Element) c.ll = list.New() } if ee, ok := c.cache[key]; ok { @@ -71,7 +71,7 @@ func (c *Cache) Add(key Key, value interface{}) { } // Get looks up a key's value from the cache. -func (c *Cache) Get(key Key) (value interface{}, ok bool) { +func (c *Cache) Get(key Key) (value any, ok bool) { if c.cache == nil { return } diff --git a/vendor/github.com/golang/protobuf/proto/deprecated.go b/vendor/github.com/golang/protobuf/proto/deprecated.go index 35b882c09..2731db59a 100644 --- a/vendor/github.com/golang/protobuf/proto/deprecated.go +++ b/vendor/github.com/golang/protobuf/proto/deprecated.go @@ -40,22 +40,22 @@ type Stats struct{ Emalloc, Dmalloc, Encode, Decode, Chit, Cmiss, Size uint64 } func GetStats() Stats { return Stats{} } // Deprecated: do not use. -func MarshalMessageSet(interface{}) ([]byte, error) { +func MarshalMessageSet(any) ([]byte, error) { return nil, errors.New("proto: not implemented") } // Deprecated: do not use. -func UnmarshalMessageSet([]byte, interface{}) error { +func UnmarshalMessageSet([]byte, any) error { return errors.New("proto: not implemented") } // Deprecated: do not use. -func MarshalMessageSetJSON(interface{}) ([]byte, error) { +func MarshalMessageSetJSON(any) ([]byte, error) { return nil, errors.New("proto: not implemented") } // Deprecated: do not use. -func UnmarshalMessageSetJSON([]byte, interface{}) error { +func UnmarshalMessageSetJSON([]byte, any) error { return errors.New("proto: not implemented") } diff --git a/vendor/github.com/golang/protobuf/proto/extensions.go b/vendor/github.com/golang/protobuf/proto/extensions.go index fa88add30..cf97ee4c0 100644 --- a/vendor/github.com/golang/protobuf/proto/extensions.go +++ b/vendor/github.com/golang/protobuf/proto/extensions.go @@ -92,7 +92,7 @@ func (n notLocker) Unlock() {} // extendable returns the extendableProto interface for the given generated proto message. // If the proto message has the old extension format, it returns a wrapper that implements // the extendableProto interface. -func extendable(p interface{}) (extendableProto, error) { +func extendable(p any) (extendableProto, error) { switch p := p.(type) { case extendableProto: if isNilPtr(p) { @@ -112,7 +112,7 @@ func extendable(p interface{}) (extendableProto, error) { var errNotExtendable = errors.New("proto: not an extendable proto.Message") -func isNilPtr(x interface{}) bool { +func isNilPtr(x any) bool { v := reflect.ValueOf(x) return v.Kind() == reflect.Ptr && v.IsNil() } @@ -162,12 +162,12 @@ func (e *XXX_InternalExtensions) extensionsRead() (map[int32]Extension, sync.Loc // ExtensionDesc represents an extension specification. // Used in generated code from the protocol compiler. type ExtensionDesc struct { - ExtendedType Message // nil pointer to the type that is being extended - ExtensionType interface{} // nil pointer to the extension type - Field int32 // field number - Name string // fully-qualified name of extension, for text formatting - Tag string // protobuf tag style - Filename string // name of the file in which the extension is defined + ExtendedType Message // nil pointer to the type that is being extended + ExtensionType any // nil pointer to the extension type + Field int32 // field number + Name string // fully-qualified name of extension, for text formatting + Tag string // protobuf tag style + Filename string // name of the file in which the extension is defined } func (ed *ExtensionDesc) repeated() bool { @@ -200,7 +200,7 @@ type Extension struct { // protobuf reflection APIs. // // The value may only be populated if desc is also populated. - value interface{} + value any // enc is the raw bytes for the extension field. enc []byte @@ -228,7 +228,7 @@ func isExtensionField(pb extendableProto, field int32) bool { // checkExtensionTypes checks that the given extension is valid for pb. func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error { - var pbi interface{} = pb + var pbi any = pb // Check the extended type. if ea, ok := pbi.(extensionAdapter); ok { pbi = ea.extendableProtoV1 @@ -316,7 +316,7 @@ func ClearExtension(pb Message, extension *ExtensionDesc) { // // If the descriptor is not type complete (i.e., ExtensionDesc.ExtensionType is nil), // then GetExtension returns the raw encoded bytes of the field extension. -func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) { +func GetExtension(pb Message, extension *ExtensionDesc) (any, error) { epb, err := extendable(pb) if err != nil { return nil, err @@ -374,7 +374,7 @@ func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) { // defaultExtensionValue returns the default value for extension. // If no default for an extension is defined ErrMissingExtension is returned. -func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) { +func defaultExtensionValue(extension *ExtensionDesc) (any, error) { if extension.ExtensionType == nil { // incomplete descriptor, so no default return nil, ErrMissingExtension @@ -413,7 +413,7 @@ func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) { } // decodeExtension decodes an extension encoded in b. -func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { +func decodeExtension(b []byte, extension *ExtensionDesc) (any, error) { t := reflect.TypeOf(extension.ExtensionType) unmarshal := typeUnmarshaler(t, extension.Tag) @@ -444,12 +444,12 @@ func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { // GetExtensions returns a slice of the extensions present in pb that are also listed in es. // The returned slice has the same length as es; missing extensions will appear as nil elements. -func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) { +func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []any, err error) { epb, err := extendable(pb) if err != nil { return nil, err } - extensions = make([]interface{}, len(es)) + extensions = make([]any, len(es)) for i, e := range es { extensions[i], err = GetExtension(epb, e) if err == ErrMissingExtension { @@ -494,7 +494,7 @@ func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) { } // SetExtension sets the specified extension of pb to the specified value. -func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error { +func SetExtension(pb Message, extension *ExtensionDesc, value any) error { epb, err := extendable(pb) if err != nil { return err @@ -560,7 +560,7 @@ func RegisteredExtensions(pb Message) map[int32]*ExtensionDesc { // extensionAsLegacyType converts an value in the storage type as the API type. // See Extension.value. -func extensionAsLegacyType(v interface{}) interface{} { +func extensionAsLegacyType(v any) any { switch rv := reflect.ValueOf(v); rv.Kind() { case reflect.Bool, reflect.Int32, reflect.Int64, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64, reflect.String: // Represent primitive types as a pointer to the value. @@ -583,7 +583,7 @@ func extensionAsLegacyType(v interface{}) interface{} { // extensionAsStorageType converts an value in the API type as the storage type. // See Extension.value. -func extensionAsStorageType(v interface{}) interface{} { +func extensionAsStorageType(v any) any { switch rv := reflect.ValueOf(v); rv.Kind() { case reflect.Ptr: // Represent slice types as the value itself. diff --git a/vendor/github.com/golang/protobuf/proto/lib.go b/vendor/github.com/golang/protobuf/proto/lib.go index fdd328bb7..56727a23f 100644 --- a/vendor/github.com/golang/protobuf/proto/lib.go +++ b/vendor/github.com/golang/protobuf/proto/lib.go @@ -39,35 +39,35 @@ for a protocol buffer variable v: - Names are turned from camel_case to CamelCase for export. - There are no methods on v to set fields; just treat - them as structure fields. + them as structure fields. - There are getters that return a field's value if set, - and return the field's default value if unset. - The getters work even if the receiver is a nil message. + and return the field's default value if unset. + The getters work even if the receiver is a nil message. - The zero value for a struct is its correct initialization state. - All desired fields must be set before marshaling. + All desired fields must be set before marshaling. - A Reset() method will restore a protobuf struct to its zero state. - Non-repeated fields are pointers to the values; nil means unset. - That is, optional or required field int32 f becomes F *int32. + That is, optional or required field int32 f becomes F *int32. - Repeated fields are slices. - Helper functions are available to aid the setting of fields. - msg.Foo = proto.String("hello") // set field + msg.Foo = proto.String("hello") // set field - Constants are defined to hold the default values of all fields that - have them. They have the form Default_StructName_FieldName. - Because the getter methods handle defaulted values, - direct use of these constants should be rare. + have them. They have the form Default_StructName_FieldName. + Because the getter methods handle defaulted values, + direct use of these constants should be rare. - Enums are given type names and maps from names to values. - Enum values are prefixed by the enclosing message's name, or by the - enum's type name if it is a top-level enum. Enum types have a String - method, and a Enum method to assist in message construction. + Enum values are prefixed by the enclosing message's name, or by the + enum's type name if it is a top-level enum. Enum types have a String + method, and a Enum method to assist in message construction. - Nested messages, groups and enums have type names prefixed with the name of - the surrounding message type. + the surrounding message type. - Extensions are given descriptor names that start with E_, - followed by an underscore-delimited list of the nested messages - that contain it (if any) followed by the CamelCased name of the - extension field itself. HasExtension, ClearExtension, GetExtension - and SetExtension are functions for manipulating extensions. + followed by an underscore-delimited list of the nested messages + that contain it (if any) followed by the CamelCased name of the + extension field itself. HasExtension, ClearExtension, GetExtension + and SetExtension are functions for manipulating extensions. - Oneof field sets are given a single field in their message, - with distinguished wrapper types for each possible field value. + with distinguished wrapper types for each possible field value. - Marshal and Unmarshal are functions to encode and decode the wire format. When the .proto file specifies `syntax="proto3"`, there are some differences: @@ -759,7 +759,7 @@ type defaultMessage struct { type scalarField struct { index int // struct field index kind reflect.Kind // element type (the T in *T or []T) - value interface{} // the proto-declared default value, or nil + value any // the proto-declared default value, or nil } // t is a struct type. diff --git a/vendor/github.com/golang/protobuf/proto/message_set.go b/vendor/github.com/golang/protobuf/proto/message_set.go index f48a75676..88ff3b435 100644 --- a/vendor/github.com/golang/protobuf/proto/message_set.go +++ b/vendor/github.com/golang/protobuf/proto/message_set.go @@ -141,7 +141,7 @@ func skipVarint(buf []byte) []byte { // unmarshalMessageSet decodes the extension map encoded in buf in the message set wire format. // It is called by Unmarshal methods on protocol buffer messages with the message_set_wire_format option. -func unmarshalMessageSet(buf []byte, exts interface{}) error { +func unmarshalMessageSet(buf []byte, exts any) error { var m map[int32]Extension switch exts := exts.(type) { case *XXX_InternalExtensions: diff --git a/vendor/github.com/golang/protobuf/proto/pointer_reflect.go b/vendor/github.com/golang/protobuf/proto/pointer_reflect.go index 94fa9194a..97d0e34d4 100644 --- a/vendor/github.com/golang/protobuf/proto/pointer_reflect.go +++ b/vendor/github.com/golang/protobuf/proto/pointer_reflect.go @@ -29,6 +29,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +//go:build purego || appengine || js // +build purego appengine js // This file contains an implementation of proto field accesses using package reflect. @@ -79,7 +80,7 @@ func toPointer(i *Message) pointer { // toAddrPointer converts an interface to a pointer that points to // the interface data. -func toAddrPointer(i *interface{}, isptr, deref bool) pointer { +func toAddrPointer(i *any, isptr, deref bool) pointer { v := reflect.ValueOf(*i) u := reflect.New(v.Type()) u.Elem().Set(v) diff --git a/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go b/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go index dbfffe071..264ef1c6d 100644 --- a/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go +++ b/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go @@ -29,6 +29,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +//go:build !purego && !appengine && !js // +build !purego,!appengine,!js // This file contains the implementation of the proto field accesses using package unsafe. @@ -85,7 +86,7 @@ func toPointer(i *Message) pointer { // toAddrPointer converts an interface to a pointer that points to // the interface data. -func toAddrPointer(i *interface{}, isptr, deref bool) (p pointer) { +func toAddrPointer(i *any, isptr, deref bool) (p pointer) { // Super-tricky - read or get the address of data word of interface value. if isptr { // The interface is of pointer type, thus it is a direct interface. diff --git a/vendor/github.com/golang/protobuf/proto/properties.go b/vendor/github.com/golang/protobuf/proto/properties.go index a4b8c0cd3..85d666399 100644 --- a/vendor/github.com/golang/protobuf/proto/properties.go +++ b/vendor/github.com/golang/protobuf/proto/properties.go @@ -344,10 +344,10 @@ func GetProperties(t reflect.Type) *StructProperties { type ( oneofFuncsIface interface { - XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) + XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []any) } oneofWrappersIface interface { - XXX_OneofWrappers() []interface{} + XXX_OneofWrappers() []any } ) @@ -390,7 +390,7 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { // Re-order prop.order. sort.Sort(prop) - var oots []interface{} + var oots []any switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) { case oneofFuncsIface: _, _, _, oots = m.XXX_OneofFuncs() @@ -495,7 +495,7 @@ func RegisterType(x Message, name string) { // RegisterMapType is called from generated code and maps from the fully qualified // proto name to the native map type of the proto map definition. -func RegisterMapType(x interface{}, name string) { +func RegisterMapType(x any, name string) { if reflect.TypeOf(x).Kind() != reflect.Map { panic(fmt.Sprintf("RegisterMapType(%T, %q); want map", x, name)) } diff --git a/vendor/github.com/golang/protobuf/proto/table_marshal.go b/vendor/github.com/golang/protobuf/proto/table_marshal.go index 5cb11fa95..4ad42b305 100644 --- a/vendor/github.com/golang/protobuf/proto/table_marshal.go +++ b/vendor/github.com/golang/protobuf/proto/table_marshal.go @@ -141,7 +141,7 @@ func (a *InternalMessageInfo) Marshal(b []byte, msg Message, deterministic bool) return u.marshal(b, ptr, deterministic) } -func getMessageMarshalInfo(msg interface{}, a *InternalMessageInfo) *marshalInfo { +func getMessageMarshalInfo(msg any, a *InternalMessageInfo) *marshalInfo { // u := a.marshal, but atomically. // We use an atomic here to ensure memory consistency. u := atomicLoadMarshalInfo(&a.marshal) @@ -320,7 +320,7 @@ func (u *marshalInfo) computeMarshalInfo() { } // get oneof implementers - var oneofImplementers []interface{} + var oneofImplementers []any switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) { case oneofFuncsIface: _, _, _, oneofImplementers = m.XXX_OneofFuncs() @@ -459,7 +459,7 @@ func (fi *marshalFieldInfo) computeMarshalFieldInfo(f *reflect.StructField) { fi.setMarshaler(f, tags) } -func (fi *marshalFieldInfo) computeOneofFieldInfo(f *reflect.StructField, oneofImplementers []interface{}) { +func (fi *marshalFieldInfo) computeOneofFieldInfo(f *reflect.StructField, oneofImplementers []any) { fi.field = toField(f) fi.wiretag = math.MaxInt32 // Use a large tag number, make oneofs sorted at the end. This tag will not appear on the wire. fi.isPointer = true diff --git a/vendor/github.com/golang/protobuf/proto/table_unmarshal.go b/vendor/github.com/golang/protobuf/proto/table_unmarshal.go index acee2fc52..ef5c4e138 100644 --- a/vendor/github.com/golang/protobuf/proto/table_unmarshal.go +++ b/vendor/github.com/golang/protobuf/proto/table_unmarshal.go @@ -362,7 +362,7 @@ func (u *unmarshalInfo) computeUnmarshalInfo() { } // Find any types associated with oneof fields. - var oneofImplementers []interface{} + var oneofImplementers []any switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) { case oneofFuncsIface: _, _, _, oneofImplementers = m.XXX_OneofFuncs() @@ -1808,12 +1808,14 @@ func makeUnmarshalMap(f *reflect.StructField) unmarshaler { // makeUnmarshalOneof makes an unmarshaler for oneof fields. // for: -// message Msg { -// oneof F { -// int64 X = 1; -// float64 Y = 2; -// } -// } +// +// message Msg { +// oneof F { +// int64 X = 1; +// float64 Y = 2; +// } +// } +// // typ is the type of the concrete entry for a oneof case (e.g. Msg_X). // ityp is the interface type of the oneof field (e.g. isMsg_F). // unmarshal is the unmarshaler for the base type of the oneof case (e.g. int64). diff --git a/vendor/github.com/golang/protobuf/proto/text.go b/vendor/github.com/golang/protobuf/proto/text.go index 1aaee725b..f55199e3d 100644 --- a/vendor/github.com/golang/protobuf/proto/text.go +++ b/vendor/github.com/golang/protobuf/proto/text.go @@ -731,7 +731,7 @@ func (tm *TextMarshaler) writeExtensions(w *textWriter, pv reflect.Value) error return nil } -func (tm *TextMarshaler) writeExtension(w *textWriter, name string, pb interface{}) error { +func (tm *TextMarshaler) writeExtension(w *textWriter, name string, pb any) error { if _, err := fmt.Fprintf(w, "[%s]:", name); err != nil { return err } diff --git a/vendor/github.com/golang/protobuf/proto/text_parser.go b/vendor/github.com/golang/protobuf/proto/text_parser.go index bb55a3af2..01eba5dba 100644 --- a/vendor/github.com/golang/protobuf/proto/text_parser.go +++ b/vendor/github.com/golang/protobuf/proto/text_parser.go @@ -92,7 +92,7 @@ func newTextParser(s string) *textParser { return p } -func (p *textParser) errorf(format string, a ...interface{}) *ParseError { +func (p *textParser) errorf(format string, a ...any) *ParseError { pe := &ParseError{fmt.Sprintf(format, a...), p.cur.line, p.cur.offset} p.cur.err = pe p.done = true diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/generator/generator.go b/vendor/github.com/golang/protobuf/protoc-gen-go/generator/generator.go index 6f4a902b5..9baff949f 100644 --- a/vendor/github.com/golang/protobuf/protoc-gen-go/generator/generator.go +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/generator/generator.go @@ -30,9 +30,9 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* - The code generator for the plugin for the Google protocol buffer compiler. - It generates Go code from the protocol buffer description files read by the - main routine. +The code generator for the plugin for the Google protocol buffer compiler. +It generates Go code from the protocol buffer description files read by the +main routine. */ package generator @@ -980,17 +980,17 @@ func (g *Generator) ObjectNamed(typeName string) Object { type AnnotatedAtoms struct { source string path string - atoms []interface{} + atoms []any } // Annotate records the file name and proto AST path of a list of atoms // so that a later call to P can emit a link from each atom to its origin. -func Annotate(file *FileDescriptor, path string, atoms ...interface{}) *AnnotatedAtoms { +func Annotate(file *FileDescriptor, path string, atoms ...any) *AnnotatedAtoms { return &AnnotatedAtoms{source: *file.Name, path: path, atoms: atoms} } // printAtom prints the (atomic, non-annotation) argument to the generated output. -func (g *Generator) printAtom(v interface{}) { +func (g *Generator) printAtom(v any) { switch v := v.(type) { case string: g.WriteString(v) @@ -1023,7 +1023,7 @@ func (g *Generator) printAtom(v interface{}) { // handling indirections because they may be *string, etc. Any inputs of type AnnotatedAtoms may emit // annotations in a .meta file in addition to outputting the atoms themselves (if g.annotateCode // is true). -func (g *Generator) P(str ...interface{}) { +func (g *Generator) P(str ...any) { if !g.writeOutput { return } @@ -1061,7 +1061,7 @@ func (g *Generator) P(str ...interface{}) { // addInitf stores the given statement to be printed inside the file's init function. // The statement is given as a format specifier and arguments. -func (g *Generator) addInitf(stmt string, a ...interface{}) { +func (g *Generator) addInitf(stmt string, a ...any) { g.init = append(g.init, fmt.Sprintf(stmt, a...)) } @@ -1452,6 +1452,7 @@ func (g *Generator) generateEnum(enum *EnumDescriptor) { // The tag is a string like "varint,2,opt,name=fieldname,def=7" that // identifies details of the field for the protocol buffer marshaling and unmarshaling // code. The fields are: +// // wire encoding // protocol tag number // opt,req,rep for optional, required, or repeated @@ -1460,6 +1461,7 @@ func (g *Generator) generateEnum(enum *EnumDescriptor) { // enum= the name of the enum type if it is an enum-typed field. // proto3 if this field is in a proto3 message // def= string representation of the default value, if any. +// // The default value must be in a representation that can be used at run-time // to generate the default value. Thus bools become 0 and 1, for instance. func (g *Generator) goTag(message *Descriptor, field *descriptor.FieldDescriptorProto, wiretype string) string { @@ -2264,7 +2266,7 @@ func (g *Generator) generateMessage(message *Descriptor) { of := oneofField{ fieldCommon: fieldCommon{ goName: fname, - getterName: "Get"+fname, + getterName: "Get" + fname, goType: dname, tags: tag, protoName: odp.GetName(), diff --git a/vendor/github.com/golang/protobuf/ptypes/struct/struct.pb.go b/vendor/github.com/golang/protobuf/ptypes/struct/struct.pb.go index 33daa73dd..101a728d9 100644 --- a/vendor/github.com/golang/protobuf/ptypes/struct/struct.pb.go +++ b/vendor/github.com/golang/protobuf/ptypes/struct/struct.pb.go @@ -23,7 +23,7 @@ const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // `NullValue` is a singleton enumeration to represent the null value for the // `Value` type union. // -// The JSON representation for `NullValue` is JSON `null`. +// The JSON representation for `NullValue` is JSON `null`. type NullValue int32 const ( @@ -238,8 +238,8 @@ func (m *Value) GetListValue() *ListValue { } // XXX_OneofWrappers is for the internal use of the proto package. -func (*Value) XXX_OneofWrappers() []interface{} { - return []interface{}{ +func (*Value) XXX_OneofWrappers() []any { + return []any{ (*Value_NullValue)(nil), (*Value_NumberValue)(nil), (*Value_StringValue)(nil), diff --git a/vendor/github.com/google/uuid/sql.go b/vendor/github.com/google/uuid/sql.go index f326b54db..bf23a9fc7 100644 --- a/vendor/github.com/google/uuid/sql.go +++ b/vendor/github.com/google/uuid/sql.go @@ -12,7 +12,7 @@ import ( // Scan implements sql.Scanner so UUIDs can be read from databases transparently // Currently, database types that map to string and []byte are supported. Please // consult database-specific driver documentation for matching types. -func (uuid *UUID) Scan(src interface{}) error { +func (uuid *UUID) Scan(src any) error { switch src := src.(type) { case nil: return nil diff --git a/vendor/github.com/gorilla/websocket/compression.go b/vendor/github.com/gorilla/websocket/compression.go index 813ffb1e8..c97298ff7 100644 --- a/vendor/github.com/gorilla/websocket/compression.go +++ b/vendor/github.com/gorilla/websocket/compression.go @@ -20,7 +20,7 @@ const ( var ( flateWriterPools [maxCompressionLevel - minCompressionLevel + 1]sync.Pool - flateReaderPool = sync.Pool{New: func() interface{} { + flateReaderPool = sync.Pool{New: func() any { return flate.NewReader(nil) }} ) diff --git a/vendor/github.com/gorilla/websocket/json.go b/vendor/github.com/gorilla/websocket/json.go index dc2c1f641..123b71849 100644 --- a/vendor/github.com/gorilla/websocket/json.go +++ b/vendor/github.com/gorilla/websocket/json.go @@ -12,7 +12,7 @@ import ( // WriteJSON writes the JSON encoding of v as a message. // // Deprecated: Use c.WriteJSON instead. -func WriteJSON(c *Conn, v interface{}) error { +func WriteJSON(c *Conn, v any) error { return c.WriteJSON(v) } @@ -20,7 +20,7 @@ func WriteJSON(c *Conn, v interface{}) error { // // See the documentation for encoding/json Marshal for details about the // conversion of Go values to JSON. -func (c *Conn) WriteJSON(v interface{}) error { +func (c *Conn) WriteJSON(v any) error { w, err := c.NextWriter(TextMessage) if err != nil { return err @@ -37,7 +37,7 @@ func (c *Conn) WriteJSON(v interface{}) error { // it in the value pointed to by v. // // Deprecated: Use c.ReadJSON instead. -func ReadJSON(c *Conn, v interface{}) error { +func ReadJSON(c *Conn, v any) error { return c.ReadJSON(v) } @@ -46,7 +46,7 @@ func ReadJSON(c *Conn, v interface{}) error { // // See the documentation for the encoding/json Unmarshal function for details // about the conversion of JSON to a Go value. -func (c *Conn) ReadJSON(v interface{}) error { +func (c *Conn) ReadJSON(v any) error { _, r, err := c.NextReader() if err != nil { return err diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go index 45a2f5f49..465a0a1ec 100644 --- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go +++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go @@ -20,13 +20,13 @@ func ChainUnaryServer(interceptors ...grpc.UnaryServerInterceptor) grpc.UnarySer if n > 1 { lastI := n - 1 - return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { var ( chainHandler grpc.UnaryHandler curI int ) - chainHandler = func(currentCtx context.Context, currentReq interface{}) (interface{}, error) { + chainHandler = func(currentCtx context.Context, currentReq any) (any, error) { if curI == lastI { return handler(currentCtx, currentReq) } @@ -45,7 +45,7 @@ func ChainUnaryServer(interceptors ...grpc.UnaryServerInterceptor) grpc.UnarySer } // n == 0; Dummy interceptor maintained for backward compatibility to avoid returning nil. - return func(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + return func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { return handler(ctx, req) } } @@ -60,13 +60,13 @@ func ChainStreamServer(interceptors ...grpc.StreamServerInterceptor) grpc.Stream if n > 1 { lastI := n - 1 - return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { + return func(srv any, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { var ( chainHandler grpc.StreamHandler curI int ) - chainHandler = func(currentSrv interface{}, currentStream grpc.ServerStream) error { + chainHandler = func(currentSrv any, currentStream grpc.ServerStream) error { if curI == lastI { return handler(currentSrv, currentStream) } @@ -85,7 +85,7 @@ func ChainStreamServer(interceptors ...grpc.StreamServerInterceptor) grpc.Stream } // n == 0; Dummy interceptor maintained for backward compatibility to avoid returning nil. - return func(srv interface{}, stream grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error { + return func(srv any, stream grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error { return handler(srv, stream) } } @@ -99,13 +99,13 @@ func ChainUnaryClient(interceptors ...grpc.UnaryClientInterceptor) grpc.UnaryCli if n > 1 { lastI := n - 1 - return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { + return func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { var ( chainHandler grpc.UnaryInvoker curI int ) - chainHandler = func(currentCtx context.Context, currentMethod string, currentReq, currentRepl interface{}, currentConn *grpc.ClientConn, currentOpts ...grpc.CallOption) error { + chainHandler = func(currentCtx context.Context, currentMethod string, currentReq, currentRepl any, currentConn *grpc.ClientConn, currentOpts ...grpc.CallOption) error { if curI == lastI { return invoker(currentCtx, currentMethod, currentReq, currentRepl, currentConn, currentOpts...) } @@ -124,7 +124,7 @@ func ChainUnaryClient(interceptors ...grpc.UnaryClientInterceptor) grpc.UnaryCli } // n == 0; Dummy interceptor maintained for backward compatibility to avoid returning nil. - return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { + return func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { return invoker(ctx, method, req, reply, cc, opts...) } } diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/doc.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/doc.go index 716895036..0c91777b0 100644 --- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/doc.go +++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/doc.go @@ -4,7 +4,7 @@ /* `grpc_middleware` is a collection of gRPC middleware packages: interceptors, helpers and tools. -Middleware +# Middleware gRPC is a fantastic RPC middleware, which sees a lot of adoption in the Golang world. However, the upstream gRPC codebase is relatively bare bones. @@ -13,7 +13,7 @@ This package, and most of its child packages provides commonly needed middleware client-side interceptors for retires, server-side interceptors for input validation and auth, functions for chaining said interceptors, metadata convenience methods and more. -Chaining +# Chaining By default, gRPC doesn't allow one to have more than one interceptor either on the client nor on the server side. `grpc_middleware` provides convenient chaining methods @@ -42,7 +42,7 @@ These interceptors will be executed from left to right: monitoring and then retr The retry interceptor will call every interceptor that follows it whenever when a retry happens. -Writing Your Own +# Writing Your Own Implementing your own interceptor is pretty trivial: there are interfaces for that. But the interesting bit exposing common data to handlers (and other middleware), similarly to HTTP Middleware design. diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/client_metrics.go b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/client_metrics.go index 9b476f983..2f538ff1a 100644 --- a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/client_metrics.go +++ b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/client_metrics.go @@ -105,8 +105,8 @@ func (m *ClientMetrics) EnableClientHandlingTimeHistogram(opts ...HistogramOptio } // UnaryClientInterceptor is a gRPC client-side interceptor that provides Prometheus monitoring for Unary RPCs. -func (m *ClientMetrics) UnaryClientInterceptor() func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { - return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { +func (m *ClientMetrics) UnaryClientInterceptor() func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { + return func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { monitor := newClientReporter(m, Unary, method) monitor.SentMessage() err := invoker(ctx, method, req, reply, cc, opts...) @@ -148,7 +148,7 @@ type monitoredClientStream struct { monitor *clientReporter } -func (s *monitoredClientStream) SendMsg(m interface{}) error { +func (s *monitoredClientStream) SendMsg(m any) error { err := s.ClientStream.SendMsg(m) if err == nil { s.monitor.SentMessage() @@ -156,7 +156,7 @@ func (s *monitoredClientStream) SendMsg(m interface{}) error { return err } -func (s *monitoredClientStream) RecvMsg(m interface{}) error { +func (s *monitoredClientStream) RecvMsg(m any) error { err := s.ClientStream.RecvMsg(m) if err == nil { s.monitor.ReceivedMessage() diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/server_metrics.go b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/server_metrics.go index 5b1467e7a..eaeca0212 100644 --- a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/server_metrics.go +++ b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/server_metrics.go @@ -100,8 +100,8 @@ func (m *ServerMetrics) Collect(ch chan<- prom.Metric) { } // UnaryServerInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Unary RPCs. -func (m *ServerMetrics) UnaryServerInterceptor() func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { - return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { +func (m *ServerMetrics) UnaryServerInterceptor() func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { + return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { monitor := newServerReporter(m, Unary, info.FullMethod) monitor.ReceivedMessage() resp, err := handler(ctx, req) @@ -115,8 +115,8 @@ func (m *ServerMetrics) UnaryServerInterceptor() func(ctx context.Context, req i } // StreamServerInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Streaming RPCs. -func (m *ServerMetrics) StreamServerInterceptor() func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { - return func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { +func (m *ServerMetrics) StreamServerInterceptor() func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { + return func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { monitor := newServerReporter(m, streamRPCType(info), info.FullMethod) err := handler(srv, &monitoredServerStream{ss, monitor}) st, _ := status.FromError(err) @@ -152,7 +152,7 @@ type monitoredServerStream struct { monitor *serverReporter } -func (s *monitoredServerStream) SendMsg(m interface{}) error { +func (s *monitoredServerStream) SendMsg(m any) error { err := s.ServerStream.SendMsg(m) if err == nil { s.monitor.SentMessage() @@ -160,7 +160,7 @@ func (s *monitoredServerStream) SendMsg(m interface{}) error { return err } -func (s *monitoredServerStream) RecvMsg(m interface{}) error { +func (s *monitoredServerStream) RecvMsg(m any) error { err := s.ServerStream.RecvMsg(m) if err == nil { s.monitor.ReceivedMessage() diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/fieldmask.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/fieldmask.go index e1cf7a914..2edb28e10 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/fieldmask.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/fieldmask.go @@ -12,7 +12,7 @@ import ( // FieldMaskFromRequestBody creates a FieldMask printing all complete paths from the JSON body. func FieldMaskFromRequestBody(r io.Reader) (*field_mask.FieldMask, error) { fm := &field_mask.FieldMask{} - var root interface{} + var root any if err := json.NewDecoder(r).Decode(&root); err != nil { if err == io.EOF { return fm, nil @@ -26,7 +26,7 @@ func FieldMaskFromRequestBody(r io.Reader) (*field_mask.FieldMask, error) { item := queue[0] queue = queue[1:] - if m, ok := item.node.(map[string]interface{}); ok { + if m, ok := item.node.(map[string]any); ok { // if the item is an object, then enqueue all of its children for k, v := range m { queue = append(queue, fieldMaskPathItem{path: append(item.path, generator.CamelCase(k)), node: v}) @@ -46,7 +46,7 @@ type fieldMaskPathItem struct { path []string // a generic decoded json object the current item to inspect for further path extraction - node interface{} + node any } // CamelCaseFieldMask updates the given FieldMask by converting all of its paths to CamelCase, using the same heuristic diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/handler.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/handler.go index 2af900650..8334ae22c 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/handler.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/handler.go @@ -109,7 +109,7 @@ func handleForwardResponseTrailer(w http.ResponseWriter, md ServerMetadata) { // responseBody interface contains method for getting field for marshaling to the response body // this method is generated for response struct from the value of `response_body` in the `google.api.HttpRule` type responseBody interface { - XXX_ResponseBody() interface{} + XXX_ResponseBody() any } // ForwardResponseMessage forwards the message "resp" from gRPC server to REST client. diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshal_httpbodyproto.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshal_httpbodyproto.go index f55285b5d..07fda9043 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshal_httpbodyproto.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshal_httpbodyproto.go @@ -26,7 +26,7 @@ func (h *HTTPBodyMarshaler) ContentType() string { // ContentTypeFromMessage in case v is a google.api.HttpBody message it returns // its specified content type otherwise fall back to the default Marshaler. -func (h *HTTPBodyMarshaler) ContentTypeFromMessage(v interface{}) string { +func (h *HTTPBodyMarshaler) ContentTypeFromMessage(v any) string { if httpBody, ok := v.(*httpbody.HttpBody); ok { return httpBody.GetContentType() } @@ -35,7 +35,7 @@ func (h *HTTPBodyMarshaler) ContentTypeFromMessage(v interface{}) string { // Marshal marshals "v" by returning the body bytes if v is a // google.api.HttpBody message, otherwise it falls back to the default Marshaler. -func (h *HTTPBodyMarshaler) Marshal(v interface{}) ([]byte, error) { +func (h *HTTPBodyMarshaler) Marshal(v any) ([]byte, error) { if httpBody, ok := v.(*httpbody.HttpBody); ok { return httpBody.Data, nil } diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshal_json.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshal_json.go index f9d3a585a..6419a13bd 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshal_json.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshal_json.go @@ -20,12 +20,12 @@ func (*JSONBuiltin) ContentType() string { } // Marshal marshals "v" into JSON -func (j *JSONBuiltin) Marshal(v interface{}) ([]byte, error) { +func (j *JSONBuiltin) Marshal(v any) ([]byte, error) { return json.Marshal(v) } // Unmarshal unmarshals JSON data into "v". -func (j *JSONBuiltin) Unmarshal(data []byte, v interface{}) error { +func (j *JSONBuiltin) Unmarshal(data []byte, v any) error { return json.Unmarshal(data, v) } diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshal_jsonpb.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshal_jsonpb.go index f0de351b2..075eae8c5 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshal_jsonpb.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshal_jsonpb.go @@ -25,7 +25,7 @@ func (*JSONPb) ContentType() string { } // Marshal marshals "v" into JSON. -func (j *JSONPb) Marshal(v interface{}) ([]byte, error) { +func (j *JSONPb) Marshal(v any) ([]byte, error) { if _, ok := v.(proto.Message); !ok { return j.marshalNonProtoField(v) } @@ -37,7 +37,7 @@ func (j *JSONPb) Marshal(v interface{}) ([]byte, error) { return buf.Bytes(), nil } -func (j *JSONPb) marshalTo(w io.Writer, v interface{}) error { +func (j *JSONPb) marshalTo(w io.Writer, v any) error { p, ok := v.(proto.Message) if !ok { buf, err := j.marshalNonProtoField(v) @@ -60,7 +60,7 @@ var ( // but it is only capable of marshaling non-message field values of protobuf, // i.e. primitive types, enums; pointers to primitives or enums; maps from // integer/string types to primitives/enums/pointers to messages. -func (j *JSONPb) marshalNonProtoField(v interface{}) ([]byte, error) { +func (j *JSONPb) marshalNonProtoField(v any) ([]byte, error) { if v == nil { return []byte("null"), nil } @@ -127,7 +127,7 @@ func (j *JSONPb) marshalNonProtoField(v interface{}) ([]byte, error) { } // Unmarshal unmarshals JSON "data" into "v" -func (j *JSONPb) Unmarshal(data []byte, v interface{}) error { +func (j *JSONPb) Unmarshal(data []byte, v any) error { return unmarshalJSONPb(data, v) } @@ -145,13 +145,13 @@ type DecoderWrapper struct { // Decode wraps the embedded decoder's Decode method to support // protos using a jsonpb.Unmarshaler. -func (d DecoderWrapper) Decode(v interface{}) error { +func (d DecoderWrapper) Decode(v any) error { return decodeJSONPb(d.Decoder, v) } // NewEncoder returns an Encoder which writes JSON stream into "w". func (j *JSONPb) NewEncoder(w io.Writer) Encoder { - return EncoderFunc(func(v interface{}) error { + return EncoderFunc(func(v any) error { if err := j.marshalTo(w, v); err != nil { return err } @@ -162,12 +162,12 @@ func (j *JSONPb) NewEncoder(w io.Writer) Encoder { }) } -func unmarshalJSONPb(data []byte, v interface{}) error { +func unmarshalJSONPb(data []byte, v any) error { d := json.NewDecoder(bytes.NewReader(data)) return decodeJSONPb(d, v) } -func decodeJSONPb(d *json.Decoder, v interface{}) error { +func decodeJSONPb(d *json.Decoder, v any) error { p, ok := v.(proto.Message) if !ok { return decodeNonProtoField(d, v) @@ -176,7 +176,7 @@ func decodeJSONPb(d *json.Decoder, v interface{}) error { return unmarshaler.UnmarshalNext(d, p) } -func decodeNonProtoField(d *json.Decoder, v interface{}) error { +func decodeNonProtoField(d *json.Decoder, v any) error { rv := reflect.ValueOf(v) if rv.Kind() != reflect.Ptr { return fmt.Errorf("%T is not a pointer", v) @@ -219,7 +219,7 @@ func decodeNonProtoField(d *json.Decoder, v interface{}) error { return nil } if _, ok := rv.Interface().(protoEnum); ok { - var repr interface{} + var repr any if err := d.Decode(&repr); err != nil { return err } diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshal_proto.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshal_proto.go index f65d1a267..121e89b4f 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshal_proto.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshal_proto.go @@ -17,7 +17,7 @@ func (*ProtoMarshaller) ContentType() string { } // Marshal marshals "value" into Proto -func (*ProtoMarshaller) Marshal(value interface{}) ([]byte, error) { +func (*ProtoMarshaller) Marshal(value any) ([]byte, error) { message, ok := value.(proto.Message) if !ok { return nil, errors.New("unable to marshal non proto field") @@ -26,7 +26,7 @@ func (*ProtoMarshaller) Marshal(value interface{}) ([]byte, error) { } // Unmarshal unmarshals proto "data" into "value" -func (*ProtoMarshaller) Unmarshal(data []byte, value interface{}) error { +func (*ProtoMarshaller) Unmarshal(data []byte, value any) error { message, ok := value.(proto.Message) if !ok { return errors.New("unable to unmarshal non proto field") @@ -36,7 +36,7 @@ func (*ProtoMarshaller) Unmarshal(data []byte, value interface{}) error { // NewDecoder returns a Decoder which reads proto stream from "reader". func (marshaller *ProtoMarshaller) NewDecoder(reader io.Reader) Decoder { - return DecoderFunc(func(value interface{}) error { + return DecoderFunc(func(value any) error { buffer, err := ioutil.ReadAll(reader) if err != nil { return err @@ -47,7 +47,7 @@ func (marshaller *ProtoMarshaller) NewDecoder(reader io.Reader) Decoder { // NewEncoder returns an Encoder which writes proto stream into "writer". func (marshaller *ProtoMarshaller) NewEncoder(writer io.Writer) Encoder { - return EncoderFunc(func(value interface{}) error { + return EncoderFunc(func(value any) error { buffer, err := marshaller.Marshal(value) if err != nil { return err diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshaler.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshaler.go index 98fe6e88a..d1bbd95ed 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshaler.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/marshaler.go @@ -7,10 +7,10 @@ import ( // Marshaler defines a conversion between byte sequence and gRPC payloads / fields. type Marshaler interface { // Marshal marshals "v" into byte sequence. - Marshal(v interface{}) ([]byte, error) + Marshal(v any) ([]byte, error) // Unmarshal unmarshals "data" into "v". // "v" must be a pointer value. - Unmarshal(data []byte, v interface{}) error + Unmarshal(data []byte, v any) error // NewDecoder returns a Decoder which reads byte sequence from "r". NewDecoder(r io.Reader) Decoder // NewEncoder returns an Encoder which writes bytes sequence into "w". @@ -21,25 +21,25 @@ type Marshaler interface { // Decoder decodes a byte sequence type Decoder interface { - Decode(v interface{}) error + Decode(v any) error } // Encoder encodes gRPC payloads / fields into byte sequence. type Encoder interface { - Encode(v interface{}) error + Encode(v any) error } // DecoderFunc adapts an decoder function into Decoder. -type DecoderFunc func(v interface{}) error +type DecoderFunc func(v any) error // Decode delegates invocations to the underlying function itself. -func (f DecoderFunc) Decode(v interface{}) error { return f(v) } +func (f DecoderFunc) Decode(v any) error { return f(v) } // EncoderFunc adapts an encoder function into Encoder -type EncoderFunc func(v interface{}) error +type EncoderFunc func(v any) error // Encode delegates invocations to the underlying function itself. -func (f EncoderFunc) Encode(v interface{}) error { return f(v) } +func (f EncoderFunc) Encode(v any) error { return f(v) } // Delimited defines the streaming delimiter. type Delimited interface { diff --git a/vendor/github.com/json-iterator/go/adapter.go b/vendor/github.com/json-iterator/go/adapter.go index 92d2cc4a3..ed190492f 100644 --- a/vendor/github.com/json-iterator/go/adapter.go +++ b/vendor/github.com/json-iterator/go/adapter.go @@ -12,17 +12,17 @@ type RawMessage []byte // // Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v. // Refer to https://godoc.org/encoding/json#Unmarshal for more information -func Unmarshal(data []byte, v interface{}) error { +func Unmarshal(data []byte, v any) error { return ConfigDefault.Unmarshal(data, v) } // UnmarshalFromString is a convenient method to read from string instead of []byte -func UnmarshalFromString(str string, v interface{}) error { +func UnmarshalFromString(str string, v any) error { return ConfigDefault.UnmarshalFromString(str, v) } // Get quick method to get value from deeply nested JSON structure -func Get(data []byte, path ...interface{}) Any { +func Get(data []byte, path ...any) Any { return ConfigDefault.Get(data, path...) } @@ -30,17 +30,17 @@ func Get(data []byte, path ...interface{}) Any { // // Marshal returns the JSON encoding of v, adapts to json/encoding Marshal API // Refer to https://godoc.org/encoding/json#Marshal for more information -func Marshal(v interface{}) ([]byte, error) { +func Marshal(v any) ([]byte, error) { return ConfigDefault.Marshal(v) } // MarshalIndent same as json.MarshalIndent. Prefix is not supported. -func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) { +func MarshalIndent(v any, prefix, indent string) ([]byte, error) { return ConfigDefault.MarshalIndent(v, prefix, indent) } // MarshalToString convenient method to write as string instead of []byte -func MarshalToString(v interface{}) (string, error) { +func MarshalToString(v any) (string, error) { return ConfigDefault.MarshalToString(v) } @@ -61,7 +61,7 @@ type Decoder struct { } // Decode decode JSON into interface{} -func (adapter *Decoder) Decode(obj interface{}) error { +func (adapter *Decoder) Decode(obj any) error { if adapter.iter.head == adapter.iter.tail && adapter.iter.reader != nil { if !adapter.iter.loadMore() { return io.EOF @@ -123,7 +123,7 @@ type Encoder struct { } // Encode encode interface{} as JSON to io.Writer -func (adapter *Encoder) Encode(val interface{}) error { +func (adapter *Encoder) Encode(val any) error { adapter.stream.WriteVal(val) adapter.stream.WriteRaw("\n") adapter.stream.Flush() diff --git a/vendor/github.com/json-iterator/go/any.go b/vendor/github.com/json-iterator/go/any.go index f6b8aeab0..a61b10f40 100644 --- a/vendor/github.com/json-iterator/go/any.go +++ b/vendor/github.com/json-iterator/go/any.go @@ -26,17 +26,17 @@ type Any interface { ToFloat32() float32 ToFloat64() float64 ToString() string - ToVal(val interface{}) - Get(path ...interface{}) Any + ToVal(val any) + Get(path ...any) Any Size() int Keys() []string - GetInterface() interface{} + GetInterface() any WriteTo(stream *Stream) } type baseAny struct{} -func (any *baseAny) Get(path ...interface{}) Any { +func (any *baseAny) Get(path ...any) Any { return &invalidAny{baseAny{}, fmt.Errorf("GetIndex %v from simple value", path)} } @@ -48,7 +48,7 @@ func (any *baseAny) Keys() []string { return []string{} } -func (any *baseAny) ToVal(obj interface{}) { +func (any *baseAny) ToVal(obj any) { panic("not implemented") } @@ -83,7 +83,7 @@ func WrapString(val string) Any { } // Wrap turn a go object into Any interface -func Wrap(val interface{}) Any { +func Wrap(val any) Any { if val == nil { return &nilAny{} } @@ -227,7 +227,7 @@ func locateArrayElement(iter *Iterator, target int) []byte { return found } -func locatePath(iter *Iterator, path []interface{}) Any { +func locatePath(iter *Iterator, path []any) Any { for i, pathKeyObj := range path { switch pathKey := pathKeyObj.(type) { case string: diff --git a/vendor/github.com/json-iterator/go/any_array.go b/vendor/github.com/json-iterator/go/any_array.go index 0449e9aa4..43e8b8177 100644 --- a/vendor/github.com/json-iterator/go/any_array.go +++ b/vendor/github.com/json-iterator/go/any_array.go @@ -90,13 +90,13 @@ func (any *arrayLazyAny) ToString() string { return *(*string)(unsafe.Pointer(&any.buf)) } -func (any *arrayLazyAny) ToVal(val interface{}) { +func (any *arrayLazyAny) ToVal(val any) { iter := any.cfg.BorrowIterator(any.buf) defer any.cfg.ReturnIterator(iter) iter.ReadVal(val) } -func (any *arrayLazyAny) Get(path ...interface{}) Any { +func (any *arrayLazyAny) Get(path ...any) Any { if len(path) == 0 { return any } @@ -146,7 +146,7 @@ func (any *arrayLazyAny) WriteTo(stream *Stream) { stream.Write(any.buf) } -func (any *arrayLazyAny) GetInterface() interface{} { +func (any *arrayLazyAny) GetInterface() any { iter := any.cfg.BorrowIterator(any.buf) defer any.cfg.ReturnIterator(iter) return iter.Read() @@ -157,7 +157,7 @@ type arrayAny struct { val reflect.Value } -func wrapArray(val interface{}) *arrayAny { +func wrapArray(val any) *arrayAny { return &arrayAny{baseAny{}, reflect.ValueOf(val)} } @@ -238,7 +238,7 @@ func (any *arrayAny) ToString() string { return str } -func (any *arrayAny) Get(path ...interface{}) Any { +func (any *arrayAny) Get(path ...any) Any { if len(path) == 0 { return any } @@ -273,6 +273,6 @@ func (any *arrayAny) WriteTo(stream *Stream) { stream.WriteVal(any.val) } -func (any *arrayAny) GetInterface() interface{} { +func (any *arrayAny) GetInterface() any { return any.val.Interface() } diff --git a/vendor/github.com/json-iterator/go/any_bool.go b/vendor/github.com/json-iterator/go/any_bool.go index 9452324af..d1beda8f4 100644 --- a/vendor/github.com/json-iterator/go/any_bool.go +++ b/vendor/github.com/json-iterator/go/any_bool.go @@ -56,7 +56,7 @@ func (any *trueAny) Parse() *Iterator { return nil } -func (any *trueAny) GetInterface() interface{} { +func (any *trueAny) GetInterface() any { return true } @@ -124,7 +124,7 @@ func (any *falseAny) Parse() *Iterator { return nil } -func (any *falseAny) GetInterface() interface{} { +func (any *falseAny) GetInterface() any { return false } diff --git a/vendor/github.com/json-iterator/go/any_float.go b/vendor/github.com/json-iterator/go/any_float.go index 35fdb0949..5cf0b14fb 100644 --- a/vendor/github.com/json-iterator/go/any_float.go +++ b/vendor/github.com/json-iterator/go/any_float.go @@ -78,6 +78,6 @@ func (any *floatAny) WriteTo(stream *Stream) { stream.WriteFloat64(any.val) } -func (any *floatAny) GetInterface() interface{} { +func (any *floatAny) GetInterface() any { return any.val } diff --git a/vendor/github.com/json-iterator/go/any_int32.go b/vendor/github.com/json-iterator/go/any_int32.go index 1b56f3991..5fbfabaf3 100644 --- a/vendor/github.com/json-iterator/go/any_int32.go +++ b/vendor/github.com/json-iterator/go/any_int32.go @@ -69,6 +69,6 @@ func (any *int32Any) Parse() *Iterator { return nil } -func (any *int32Any) GetInterface() interface{} { +func (any *int32Any) GetInterface() any { return any.val } diff --git a/vendor/github.com/json-iterator/go/any_int64.go b/vendor/github.com/json-iterator/go/any_int64.go index c440d72b6..14bcc6c47 100644 --- a/vendor/github.com/json-iterator/go/any_int64.go +++ b/vendor/github.com/json-iterator/go/any_int64.go @@ -69,6 +69,6 @@ func (any *int64Any) Parse() *Iterator { return nil } -func (any *int64Any) GetInterface() interface{} { +func (any *int64Any) GetInterface() any { return any.val } diff --git a/vendor/github.com/json-iterator/go/any_invalid.go b/vendor/github.com/json-iterator/go/any_invalid.go index 1d859eac3..e35d0b044 100644 --- a/vendor/github.com/json-iterator/go/any_invalid.go +++ b/vendor/github.com/json-iterator/go/any_invalid.go @@ -7,7 +7,7 @@ type invalidAny struct { err error } -func newInvalidAny(path []interface{}) *invalidAny { +func newInvalidAny(path []any) *invalidAny { return &invalidAny{baseAny{}, fmt.Errorf("%v not found", path)} } @@ -66,7 +66,7 @@ func (any *invalidAny) ToString() string { func (any *invalidAny) WriteTo(stream *Stream) { } -func (any *invalidAny) Get(path ...interface{}) Any { +func (any *invalidAny) Get(path ...any) Any { if any.err == nil { return &invalidAny{baseAny{}, fmt.Errorf("get %v from invalid", path)} } @@ -77,6 +77,6 @@ func (any *invalidAny) Parse() *Iterator { return nil } -func (any *invalidAny) GetInterface() interface{} { +func (any *invalidAny) GetInterface() any { return nil } diff --git a/vendor/github.com/json-iterator/go/any_nil.go b/vendor/github.com/json-iterator/go/any_nil.go index d04cb54c1..dce8dc154 100644 --- a/vendor/github.com/json-iterator/go/any_nil.go +++ b/vendor/github.com/json-iterator/go/any_nil.go @@ -64,6 +64,6 @@ func (any *nilAny) Parse() *Iterator { return nil } -func (any *nilAny) GetInterface() interface{} { +func (any *nilAny) GetInterface() any { return nil } diff --git a/vendor/github.com/json-iterator/go/any_number.go b/vendor/github.com/json-iterator/go/any_number.go index 9d1e901a6..4071de802 100644 --- a/vendor/github.com/json-iterator/go/any_number.go +++ b/vendor/github.com/json-iterator/go/any_number.go @@ -116,7 +116,7 @@ func (any *numberLazyAny) WriteTo(stream *Stream) { stream.Write(any.buf) } -func (any *numberLazyAny) GetInterface() interface{} { +func (any *numberLazyAny) GetInterface() any { iter := any.cfg.BorrowIterator(any.buf) defer any.cfg.ReturnIterator(iter) return iter.Read() diff --git a/vendor/github.com/json-iterator/go/any_object.go b/vendor/github.com/json-iterator/go/any_object.go index c44ef5c98..152c10d8a 100644 --- a/vendor/github.com/json-iterator/go/any_object.go +++ b/vendor/github.com/json-iterator/go/any_object.go @@ -64,13 +64,13 @@ func (any *objectLazyAny) ToString() string { return *(*string)(unsafe.Pointer(&any.buf)) } -func (any *objectLazyAny) ToVal(obj interface{}) { +func (any *objectLazyAny) ToVal(obj any) { iter := any.cfg.BorrowIterator(any.buf) defer any.cfg.ReturnIterator(iter) iter.ReadVal(obj) } -func (any *objectLazyAny) Get(path ...interface{}) Any { +func (any *objectLazyAny) Get(path ...any) Any { if len(path) == 0 { return any } @@ -132,7 +132,7 @@ func (any *objectLazyAny) WriteTo(stream *Stream) { stream.Write(any.buf) } -func (any *objectLazyAny) GetInterface() interface{} { +func (any *objectLazyAny) GetInterface() any { iter := any.cfg.BorrowIterator(any.buf) defer any.cfg.ReturnIterator(iter) return iter.Read() @@ -144,7 +144,7 @@ type objectAny struct { val reflect.Value } -func wrapStruct(val interface{}) *objectAny { +func wrapStruct(val any) *objectAny { return &objectAny{baseAny{}, nil, reflect.ValueOf(val)} } @@ -206,7 +206,7 @@ func (any *objectAny) ToString() string { return str } -func (any *objectAny) Get(path ...interface{}) Any { +func (any *objectAny) Get(path ...any) Any { if len(path) == 0 { return any } @@ -253,7 +253,7 @@ func (any *objectAny) WriteTo(stream *Stream) { stream.WriteVal(any.val) } -func (any *objectAny) GetInterface() interface{} { +func (any *objectAny) GetInterface() any { return any.val.Interface() } @@ -263,7 +263,7 @@ type mapAny struct { val reflect.Value } -func wrapMap(val interface{}) *mapAny { +func wrapMap(val any) *mapAny { return &mapAny{baseAny{}, nil, reflect.ValueOf(val)} } @@ -325,7 +325,7 @@ func (any *mapAny) ToString() string { return str } -func (any *mapAny) Get(path ...interface{}) Any { +func (any *mapAny) Get(path ...any) Any { if len(path) == 0 { return any } @@ -369,6 +369,6 @@ func (any *mapAny) WriteTo(stream *Stream) { stream.WriteVal(any.val) } -func (any *mapAny) GetInterface() interface{} { +func (any *mapAny) GetInterface() any { return any.val.Interface() } diff --git a/vendor/github.com/json-iterator/go/any_str.go b/vendor/github.com/json-iterator/go/any_str.go index a4b93c78c..acf9d6082 100644 --- a/vendor/github.com/json-iterator/go/any_str.go +++ b/vendor/github.com/json-iterator/go/any_str.go @@ -10,7 +10,7 @@ type stringAny struct { val string } -func (any *stringAny) Get(path ...interface{}) Any { +func (any *stringAny) Get(path ...any) Any { if len(path) == 0 { return any } @@ -161,6 +161,6 @@ func (any *stringAny) WriteTo(stream *Stream) { stream.WriteString(any.val) } -func (any *stringAny) GetInterface() interface{} { +func (any *stringAny) GetInterface() any { return any.val } diff --git a/vendor/github.com/json-iterator/go/any_uint32.go b/vendor/github.com/json-iterator/go/any_uint32.go index 656bbd33d..7c2023e9b 100644 --- a/vendor/github.com/json-iterator/go/any_uint32.go +++ b/vendor/github.com/json-iterator/go/any_uint32.go @@ -69,6 +69,6 @@ func (any *uint32Any) Parse() *Iterator { return nil } -func (any *uint32Any) GetInterface() interface{} { +func (any *uint32Any) GetInterface() any { return any.val } diff --git a/vendor/github.com/json-iterator/go/any_uint64.go b/vendor/github.com/json-iterator/go/any_uint64.go index 7df2fce33..1522c0dc8 100644 --- a/vendor/github.com/json-iterator/go/any_uint64.go +++ b/vendor/github.com/json-iterator/go/any_uint64.go @@ -69,6 +69,6 @@ func (any *uint64Any) Parse() *Iterator { return nil } -func (any *uint64Any) GetInterface() interface{} { +func (any *uint64Any) GetInterface() any { return any.val } diff --git a/vendor/github.com/json-iterator/go/config.go b/vendor/github.com/json-iterator/go/config.go index 8c58fcba5..377e90d63 100644 --- a/vendor/github.com/json-iterator/go/config.go +++ b/vendor/github.com/json-iterator/go/config.go @@ -32,12 +32,12 @@ type Config struct { type API interface { IteratorPool StreamPool - MarshalToString(v interface{}) (string, error) - Marshal(v interface{}) ([]byte, error) - MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) - UnmarshalFromString(str string, v interface{}) error - Unmarshal(data []byte, v interface{}) error - Get(data []byte, path ...interface{}) Any + MarshalToString(v any) (string, error) + Marshal(v any) ([]byte, error) + MarshalIndent(v any, prefix, indent string) ([]byte, error) + UnmarshalFromString(str string, v any) error + Unmarshal(data []byte, v any) error + Get(data []byte, path ...any) Any NewEncoder(writer io.Writer) *Encoder NewDecoder(reader io.Reader) *Decoder Valid(data []byte) bool @@ -136,12 +136,12 @@ func (cfg Config) Froze() API { caseSensitive: cfg.CaseSensitive, } api.streamPool = &sync.Pool{ - New: func() interface{} { + New: func() any { return NewStream(api, nil, 512) }, } api.iteratorPool = &sync.Pool{ - New: func() interface{} { + New: func() any { return NewIterator(api) }, } @@ -198,16 +198,16 @@ func (cfg *frozenConfig) validateJsonRawMessage(extension EncoderExtension) { } func (cfg *frozenConfig) useNumber(extension DecoderExtension) { - extension[reflect2.TypeOfPtr((*interface{})(nil)).Elem()] = &funcDecoder{func(ptr unsafe.Pointer, iter *Iterator) { - exitingValue := *((*interface{})(ptr)) + extension[reflect2.TypeOfPtr((*any)(nil)).Elem()] = &funcDecoder{func(ptr unsafe.Pointer, iter *Iterator) { + exitingValue := *((*any)(ptr)) if exitingValue != nil && reflect.TypeOf(exitingValue).Kind() == reflect.Ptr { iter.ReadVal(exitingValue) return } if iter.WhatIsNext() == NumberValue { - *((*interface{})(ptr)) = json.Number(iter.readNumberAsString()) + *((*any)(ptr)) = json.Number(iter.readNumberAsString()) } else { - *((*interface{})(ptr)) = iter.Read() + *((*any)(ptr)) = iter.Read() } }} } @@ -283,7 +283,7 @@ func (cfg *frozenConfig) cleanEncoders() { *cfg = *(cfg.configBeforeFrozen.Froze().(*frozenConfig)) } -func (cfg *frozenConfig) MarshalToString(v interface{}) (string, error) { +func (cfg *frozenConfig) MarshalToString(v any) (string, error) { stream := cfg.BorrowStream(nil) defer cfg.ReturnStream(stream) stream.WriteVal(v) @@ -293,7 +293,7 @@ func (cfg *frozenConfig) MarshalToString(v interface{}) (string, error) { return string(stream.Buffer()), nil } -func (cfg *frozenConfig) Marshal(v interface{}) ([]byte, error) { +func (cfg *frozenConfig) Marshal(v any) ([]byte, error) { stream := cfg.BorrowStream(nil) defer cfg.ReturnStream(stream) stream.WriteVal(v) @@ -306,7 +306,7 @@ func (cfg *frozenConfig) Marshal(v interface{}) ([]byte, error) { return copied, nil } -func (cfg *frozenConfig) MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) { +func (cfg *frozenConfig) MarshalIndent(v any, prefix, indent string) ([]byte, error) { if prefix != "" { panic("prefix is not supported") } @@ -320,7 +320,7 @@ func (cfg *frozenConfig) MarshalIndent(v interface{}, prefix, indent string) ([] return newCfg.frozeWithCacheReuse(cfg.extraExtensions).Marshal(v) } -func (cfg *frozenConfig) UnmarshalFromString(str string, v interface{}) error { +func (cfg *frozenConfig) UnmarshalFromString(str string, v any) error { data := []byte(str) iter := cfg.BorrowIterator(data) defer cfg.ReturnIterator(iter) @@ -336,13 +336,13 @@ func (cfg *frozenConfig) UnmarshalFromString(str string, v interface{}) error { return iter.Error } -func (cfg *frozenConfig) Get(data []byte, path ...interface{}) Any { +func (cfg *frozenConfig) Get(data []byte, path ...any) Any { iter := cfg.BorrowIterator(data) defer cfg.ReturnIterator(iter) return locatePath(iter, path) } -func (cfg *frozenConfig) Unmarshal(data []byte, v interface{}) error { +func (cfg *frozenConfig) Unmarshal(data []byte, v any) error { iter := cfg.BorrowIterator(data) defer cfg.ReturnIterator(iter) iter.ReadVal(v) diff --git a/vendor/github.com/json-iterator/go/iter.go b/vendor/github.com/json-iterator/go/iter.go index 95ae54fbf..f4b03d25e 100644 --- a/vendor/github.com/json-iterator/go/iter.go +++ b/vendor/github.com/json-iterator/go/iter.go @@ -77,7 +77,7 @@ type Iterator struct { captureStartedAt int captured []byte Error error - Attachment interface{} // open for customized decoder + Attachment any // open for customized decoder } // NewIterator creates an empty Iterator instance @@ -282,7 +282,7 @@ func (iter *Iterator) unreadByte() { } // Read read the next JSON element as generic interface{}. -func (iter *Iterator) Read() interface{} { +func (iter *Iterator) Read() any { valueType := iter.WhatIsNext() switch valueType { case StringValue: @@ -298,18 +298,18 @@ func (iter *Iterator) Read() interface{} { case BoolValue: return iter.ReadBool() case ArrayValue: - arr := []interface{}{} + arr := []any{} iter.ReadArrayCB(func(iter *Iterator) bool { - var elem interface{} + var elem any iter.ReadVal(&elem) arr = append(arr, elem) return true }) return arr case ObjectValue: - obj := map[string]interface{}{} + obj := map[string]any{} iter.ReadMapCB(func(Iter *Iterator, field string) bool { - var elem interface{} + var elem any iter.ReadVal(&elem) obj[field] = elem return true diff --git a/vendor/github.com/json-iterator/go/reflect.go b/vendor/github.com/json-iterator/go/reflect.go index 4459e203f..8a979eaf4 100644 --- a/vendor/github.com/json-iterator/go/reflect.go +++ b/vendor/github.com/json-iterator/go/reflect.go @@ -59,7 +59,7 @@ func (b *ctx) append(prefix string) *ctx { } // ReadVal copy the underlying JSON into go interface, same as json.Unmarshal -func (iter *Iterator) ReadVal(obj interface{}) { +func (iter *Iterator) ReadVal(obj any) { cacheKey := reflect2.RTypeOf(obj) decoder := iter.cfg.getDecoderFromCache(cacheKey) if decoder == nil { @@ -79,7 +79,7 @@ func (iter *Iterator) ReadVal(obj interface{}) { } // WriteVal copy the go interface into underlying JSON, same as json.Marshal -func (stream *Stream) WriteVal(val interface{}) { +func (stream *Stream) WriteVal(val any) { if nil == val { stream.WriteNil() return diff --git a/vendor/github.com/json-iterator/go/reflect_dynamic.go b/vendor/github.com/json-iterator/go/reflect_dynamic.go index 8b6bc8b43..bb1427288 100644 --- a/vendor/github.com/json-iterator/go/reflect_dynamic.go +++ b/vendor/github.com/json-iterator/go/reflect_dynamic.go @@ -23,7 +23,7 @@ type efaceDecoder struct { } func (decoder *efaceDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) { - pObj := (*interface{})(ptr) + pObj := (*any)(ptr) obj := *pObj if obj == nil { *pObj = iter.Read() diff --git a/vendor/github.com/json-iterator/go/reflect_json_number.go b/vendor/github.com/json-iterator/go/reflect_json_number.go index 98d45c1ec..fb47aa67f 100644 --- a/vendor/github.com/json-iterator/go/reflect_json_number.go +++ b/vendor/github.com/json-iterator/go/reflect_json_number.go @@ -22,7 +22,7 @@ func (n Number) Int64() (int64, error) { return strconv.ParseInt(string(n), 10, 64) } -func CastJsonNumber(val interface{}) (string, bool) { +func CastJsonNumber(val any) (string, bool) { switch typedVal := val.(type) { case json.Number: return string(typedVal), true diff --git a/vendor/github.com/json-iterator/go/stream.go b/vendor/github.com/json-iterator/go/stream.go index 17662fded..fdb0ee5ad 100644 --- a/vendor/github.com/json-iterator/go/stream.go +++ b/vendor/github.com/json-iterator/go/stream.go @@ -12,7 +12,7 @@ type Stream struct { buf []byte Error error indention int - Attachment interface{} // open for customized encoder + Attachment any // open for customized encoder } // NewStream create new stream instance. diff --git a/vendor/github.com/modern-go/concurrent/go_below_19.go b/vendor/github.com/modern-go/concurrent/go_below_19.go index b9c8df7f4..d2b7162bc 100644 --- a/vendor/github.com/modern-go/concurrent/go_below_19.go +++ b/vendor/github.com/modern-go/concurrent/go_below_19.go @@ -1,4 +1,5 @@ -//+build !go1.9 +//go:build !go1.9 +// +build !go1.9 package concurrent @@ -7,18 +8,18 @@ import "sync" // Map implements a thread safe map for go version below 1.9 using mutex type Map struct { lock sync.RWMutex - data map[interface{}]interface{} + data map[any]any } // NewMap creates a thread safe map func NewMap() *Map { return &Map{ - data: make(map[interface{}]interface{}, 32), + data: make(map[any]any, 32), } } // Load is same as sync.Map Load -func (m *Map) Load(key interface{}) (elem interface{}, found bool) { +func (m *Map) Load(key any) (elem any, found bool) { m.lock.RLock() elem, found = m.data[key] m.lock.RUnlock() @@ -26,7 +27,7 @@ func (m *Map) Load(key interface{}) (elem interface{}, found bool) { } // Load is same as sync.Map Store -func (m *Map) Store(key interface{}, elem interface{}) { +func (m *Map) Store(key any, elem any) { m.lock.Lock() m.data[key] = elem m.lock.Unlock() diff --git a/vendor/github.com/modern-go/concurrent/unbounded_executor.go b/vendor/github.com/modern-go/concurrent/unbounded_executor.go index 05a77dceb..865218a36 100644 --- a/vendor/github.com/modern-go/concurrent/unbounded_executor.go +++ b/vendor/github.com/modern-go/concurrent/unbounded_executor.go @@ -3,15 +3,15 @@ package concurrent import ( "context" "fmt" + "reflect" "runtime" "runtime/debug" "sync" "time" - "reflect" ) // HandlePanic logs goroutine panic by default -var HandlePanic = func(recovered interface{}, funcName string) { +var HandlePanic = func(recovered any, funcName string) { ErrorLogger.Println(fmt.Sprintf("%s panic: %v", funcName, recovered)) ErrorLogger.Println(string(debug.Stack())) } @@ -23,7 +23,7 @@ type UnboundedExecutor struct { cancel context.CancelFunc activeGoroutinesMutex *sync.Mutex activeGoroutines map[string]int - HandlePanic func(recovered interface{}, funcName string) + HandlePanic func(recovered any, funcName string) } // GlobalUnboundedExecutor has the life cycle of the program itself diff --git a/vendor/github.com/modern-go/reflect2/reflect2.go b/vendor/github.com/modern-go/reflect2/reflect2.go index 63b49c799..e8cce9653 100644 --- a/vendor/github.com/modern-go/reflect2/reflect2.go +++ b/vendor/github.com/modern-go/reflect2/reflect2.go @@ -9,15 +9,15 @@ import ( type Type interface { Kind() reflect.Kind // New return pointer to data of this type - New() interface{} + New() any // UnsafeNew return the allocated space pointed by unsafe.Pointer UnsafeNew() unsafe.Pointer // PackEFace cast a unsafe pointer to object represented pointer - PackEFace(ptr unsafe.Pointer) interface{} + PackEFace(ptr unsafe.Pointer) any // Indirect dereference object represented pointer to this type - Indirect(obj interface{}) interface{} + Indirect(obj any) any // UnsafeIndirect dereference pointer to this type - UnsafeIndirect(ptr unsafe.Pointer) interface{} + UnsafeIndirect(ptr unsafe.Pointer) any // Type1 returns reflect.Type Type1() reflect.Type Implements(thatType Type) bool @@ -26,9 +26,9 @@ type Type interface { // interface{} of this type has pointer like behavior LikePtr() bool IsNullable() bool - IsNil(obj interface{}) bool + IsNil(obj any) bool UnsafeIsNil(ptr unsafe.Pointer) bool - Set(obj interface{}, val interface{}) + Set(obj any, val any) UnsafeSet(ptr unsafe.Pointer, val unsafe.Pointer) AssignableTo(anotherType Type) bool } @@ -36,9 +36,9 @@ type Type interface { type ListType interface { Type Elem() Type - SetIndex(obj interface{}, index int, elem interface{}) + SetIndex(obj any, index int, elem any) UnsafeSetIndex(obj unsafe.Pointer, index int, elem unsafe.Pointer) - GetIndex(obj interface{}, index int) interface{} + GetIndex(obj any, index int) any UnsafeGetIndex(obj unsafe.Pointer, index int) unsafe.Pointer } @@ -49,17 +49,17 @@ type ArrayType interface { type SliceType interface { ListType - MakeSlice(length int, cap int) interface{} + MakeSlice(length int, cap int) any UnsafeMakeSlice(length int, cap int) unsafe.Pointer - Grow(obj interface{}, newLength int) + Grow(obj any, newLength int) UnsafeGrow(ptr unsafe.Pointer, newLength int) - Append(obj interface{}, elem interface{}) + Append(obj any, elem any) UnsafeAppend(obj unsafe.Pointer, elem unsafe.Pointer) - LengthOf(obj interface{}) int + LengthOf(obj any) int UnsafeLengthOf(ptr unsafe.Pointer) int - SetNil(obj interface{}) + SetNil(obj any) UnsafeSetNil(ptr unsafe.Pointer) - Cap(obj interface{}) int + Cap(obj any) int UnsafeCap(ptr unsafe.Pointer) int } @@ -80,9 +80,9 @@ type StructField interface { Tag() reflect.StructTag Index() []int Anonymous() bool - Set(obj interface{}, value interface{}) + Set(obj any, value any) UnsafeSet(obj unsafe.Pointer, value unsafe.Pointer) - Get(obj interface{}) interface{} + Get(obj any) any UnsafeGet(obj unsafe.Pointer) unsafe.Pointer } @@ -90,20 +90,20 @@ type MapType interface { Type Key() Type Elem() Type - MakeMap(cap int) interface{} + MakeMap(cap int) any UnsafeMakeMap(cap int) unsafe.Pointer - SetIndex(obj interface{}, key interface{}, elem interface{}) + SetIndex(obj any, key any, elem any) UnsafeSetIndex(obj unsafe.Pointer, key unsafe.Pointer, elem unsafe.Pointer) - TryGetIndex(obj interface{}, key interface{}) (interface{}, bool) - GetIndex(obj interface{}, key interface{}) interface{} + TryGetIndex(obj any, key any) (any, bool) + GetIndex(obj any, key any) any UnsafeGetIndex(obj unsafe.Pointer, key unsafe.Pointer) unsafe.Pointer - Iterate(obj interface{}) MapIterator + Iterate(obj any) MapIterator UnsafeIterate(obj unsafe.Pointer) MapIterator } type MapIterator interface { HasNext() bool - Next() (key interface{}, elem interface{}) + Next() (key any, elem any) UnsafeNext() (key unsafe.Pointer, elem unsafe.Pointer) } @@ -121,7 +121,7 @@ type Config struct { } type API interface { - TypeOf(obj interface{}) Type + TypeOf(obj any) Type Type2(type1 reflect.Type) Type } @@ -136,11 +136,11 @@ type frozenConfig struct { func (cfg Config) Froze() *frozenConfig { return &frozenConfig{ useSafeImplementation: cfg.UseSafeImplementation, - cache: concurrent.NewMap(), + cache: concurrent.NewMap(), } } -func (cfg *frozenConfig) TypeOf(obj interface{}) Type { +func (cfg *frozenConfig) TypeOf(obj any) Type { cacheKey := uintptr(unpackEFace(obj).rtype) typeObj, found := cfg.cache.Load(cacheKey) if found { @@ -207,11 +207,11 @@ func (cfg *frozenConfig) wrapType(type1 reflect.Type) Type { } } -func TypeOf(obj interface{}) Type { +func TypeOf(obj any) Type { return ConfigUnsafe.TypeOf(obj) } -func TypeOfPtr(obj interface{}) PtrType { +func TypeOfPtr(obj any) PtrType { return TypeOf(obj).(PtrType) } @@ -226,15 +226,15 @@ func PtrTo(typ Type) Type { return Type2(reflect.PtrTo(typ.Type1())) } -func PtrOf(obj interface{}) unsafe.Pointer { +func PtrOf(obj any) unsafe.Pointer { return unpackEFace(obj).data } -func RTypeOf(obj interface{}) uintptr { +func RTypeOf(obj any) uintptr { return uintptr(unpackEFace(obj).rtype) } -func IsNil(obj interface{}) bool { +func IsNil(obj any) bool { if obj == nil { return true } @@ -281,6 +281,7 @@ func likePtrType(typ reflect.Type) bool { // output depends on the input. noescape is inlined and currently // compiles down to zero instructions. // USE CAREFULLY! +// //go:nosplit func NoEscape(p unsafe.Pointer) unsafe.Pointer { x := uintptr(p) @@ -291,8 +292,8 @@ func UnsafeCastString(str string) []byte { stringHeader := (*reflect.StringHeader)(unsafe.Pointer(&str)) sliceHeader := &reflect.SliceHeader{ Data: stringHeader.Data, - Cap: stringHeader.Len, - Len: stringHeader.Len, + Cap: stringHeader.Len, + Len: stringHeader.Len, } return *(*[]byte)(unsafe.Pointer(sliceHeader)) } diff --git a/vendor/github.com/modern-go/reflect2/safe_field.go b/vendor/github.com/modern-go/reflect2/safe_field.go index d4ba1f4f8..73f439349 100644 --- a/vendor/github.com/modern-go/reflect2/safe_field.go +++ b/vendor/github.com/modern-go/reflect2/safe_field.go @@ -37,7 +37,7 @@ func (field *safeField) Anonymous() bool { return field.StructField.Anonymous } -func (field *safeField) Set(obj interface{}, value interface{}) { +func (field *safeField) Set(obj any, value any) { val := reflect.ValueOf(obj).Elem() val.FieldByIndex(field.Index()).Set(reflect.ValueOf(value).Elem()) } @@ -46,7 +46,7 @@ func (field *safeField) UnsafeSet(obj unsafe.Pointer, value unsafe.Pointer) { panic("unsafe operation is not supported") } -func (field *safeField) Get(obj interface{}) interface{} { +func (field *safeField) Get(obj any) any { val := reflect.ValueOf(obj).Elem().FieldByIndex(field.Index()) ptr := reflect.New(val.Type()) ptr.Elem().Set(val) diff --git a/vendor/github.com/modern-go/reflect2/safe_map.go b/vendor/github.com/modern-go/reflect2/safe_map.go index 88362205a..263f49931 100644 --- a/vendor/github.com/modern-go/reflect2/safe_map.go +++ b/vendor/github.com/modern-go/reflect2/safe_map.go @@ -13,7 +13,7 @@ func (type2 *safeMapType) Key() Type { return type2.safeType.cfg.Type2(type2.Type.Key()) } -func (type2 *safeMapType) MakeMap(cap int) interface{} { +func (type2 *safeMapType) MakeMap(cap int) any { ptr := reflect.New(type2.Type) ptr.Elem().Set(reflect.MakeMap(type2.Type)) return ptr.Interface() @@ -23,7 +23,7 @@ func (type2 *safeMapType) UnsafeMakeMap(cap int) unsafe.Pointer { panic("does not support unsafe operation") } -func (type2 *safeMapType) SetIndex(obj interface{}, key interface{}, elem interface{}) { +func (type2 *safeMapType) SetIndex(obj any, key any, elem any) { keyVal := reflect.ValueOf(key) elemVal := reflect.ValueOf(elem) val := reflect.ValueOf(obj) @@ -34,7 +34,7 @@ func (type2 *safeMapType) UnsafeSetIndex(obj unsafe.Pointer, key unsafe.Pointer, panic("does not support unsafe operation") } -func (type2 *safeMapType) TryGetIndex(obj interface{}, key interface{}) (interface{}, bool) { +func (type2 *safeMapType) TryGetIndex(obj any, key any) (any, bool) { keyVal := reflect.ValueOf(key) if key == nil { keyVal = reflect.New(type2.Type.Key()).Elem() @@ -46,7 +46,7 @@ func (type2 *safeMapType) TryGetIndex(obj interface{}, key interface{}) (interfa return val.Interface(), true } -func (type2 *safeMapType) GetIndex(obj interface{}, key interface{}) interface{} { +func (type2 *safeMapType) GetIndex(obj any, key any) any { val := reflect.ValueOf(obj).Elem() keyVal := reflect.ValueOf(key).Elem() elemVal := val.MapIndex(keyVal) @@ -63,7 +63,7 @@ func (type2 *safeMapType) UnsafeGetIndex(obj unsafe.Pointer, key unsafe.Pointer) panic("does not support unsafe operation") } -func (type2 *safeMapType) Iterate(obj interface{}) MapIterator { +func (type2 *safeMapType) Iterate(obj any) MapIterator { m := reflect.ValueOf(obj).Elem() return &safeMapIterator{ m: m, @@ -85,7 +85,7 @@ func (iter *safeMapIterator) HasNext() bool { return iter.i != len(iter.keys) } -func (iter *safeMapIterator) Next() (interface{}, interface{}) { +func (iter *safeMapIterator) Next() (any, any) { key := iter.keys[iter.i] elem := iter.m.MapIndex(key) iter.i += 1 diff --git a/vendor/github.com/modern-go/reflect2/safe_slice.go b/vendor/github.com/modern-go/reflect2/safe_slice.go index bcce6fd20..ed54f3671 100644 --- a/vendor/github.com/modern-go/reflect2/safe_slice.go +++ b/vendor/github.com/modern-go/reflect2/safe_slice.go @@ -9,7 +9,7 @@ type safeSliceType struct { safeType } -func (type2 *safeSliceType) SetIndex(obj interface{}, index int, value interface{}) { +func (type2 *safeSliceType) SetIndex(obj any, index int, value any) { val := reflect.ValueOf(obj).Elem() elem := reflect.ValueOf(value).Elem() val.Index(index).Set(elem) @@ -19,7 +19,7 @@ func (type2 *safeSliceType) UnsafeSetIndex(obj unsafe.Pointer, index int, value panic("does not support unsafe operation") } -func (type2 *safeSliceType) GetIndex(obj interface{}, index int) interface{} { +func (type2 *safeSliceType) GetIndex(obj any, index int) any { val := reflect.ValueOf(obj).Elem() elem := val.Index(index) ptr := reflect.New(elem.Type()) @@ -31,7 +31,7 @@ func (type2 *safeSliceType) UnsafeGetIndex(obj unsafe.Pointer, index int) unsafe panic("does not support unsafe operation") } -func (type2 *safeSliceType) MakeSlice(length int, cap int) interface{} { +func (type2 *safeSliceType) MakeSlice(length int, cap int) any { val := reflect.MakeSlice(type2.Type, length, cap) ptr := reflect.New(val.Type()) ptr.Elem().Set(val) @@ -42,7 +42,7 @@ func (type2 *safeSliceType) UnsafeMakeSlice(length int, cap int) unsafe.Pointer panic("does not support unsafe operation") } -func (type2 *safeSliceType) Grow(obj interface{}, newLength int) { +func (type2 *safeSliceType) Grow(obj any, newLength int) { oldCap := type2.Cap(obj) oldSlice := reflect.ValueOf(obj).Elem() delta := newLength - oldCap @@ -55,7 +55,7 @@ func (type2 *safeSliceType) UnsafeGrow(ptr unsafe.Pointer, newLength int) { panic("does not support unsafe operation") } -func (type2 *safeSliceType) Append(obj interface{}, elem interface{}) { +func (type2 *safeSliceType) Append(obj any, elem any) { val := reflect.ValueOf(obj).Elem() elemVal := reflect.ValueOf(elem).Elem() newVal := reflect.Append(val, elemVal) @@ -66,7 +66,7 @@ func (type2 *safeSliceType) UnsafeAppend(obj unsafe.Pointer, elem unsafe.Pointer panic("does not support unsafe operation") } -func (type2 *safeSliceType) SetNil(obj interface{}) { +func (type2 *safeSliceType) SetNil(obj any) { val := reflect.ValueOf(obj).Elem() val.Set(reflect.Zero(val.Type())) } @@ -75,7 +75,7 @@ func (type2 *safeSliceType) UnsafeSetNil(ptr unsafe.Pointer) { panic("does not support unsafe operation") } -func (type2 *safeSliceType) LengthOf(obj interface{}) int { +func (type2 *safeSliceType) LengthOf(obj any) int { return reflect.ValueOf(obj).Elem().Len() } @@ -83,7 +83,7 @@ func (type2 *safeSliceType) UnsafeLengthOf(ptr unsafe.Pointer) int { panic("does not support unsafe operation") } -func (type2 *safeSliceType) Cap(obj interface{}) int { +func (type2 *safeSliceType) Cap(obj any) int { return reflect.ValueOf(obj).Elem().Cap() } diff --git a/vendor/github.com/modern-go/reflect2/safe_type.go b/vendor/github.com/modern-go/reflect2/safe_type.go index ee4e7bb6e..accc37344 100644 --- a/vendor/github.com/modern-go/reflect2/safe_type.go +++ b/vendor/github.com/modern-go/reflect2/safe_type.go @@ -10,7 +10,7 @@ type safeType struct { cfg *frozenConfig } -func (type2 *safeType) New() interface{} { +func (type2 *safeType) New() any { return reflect.New(type2.Type).Interface() } @@ -26,7 +26,7 @@ func (type2 *safeType) Type1() reflect.Type { return type2.Type } -func (type2 *safeType) PackEFace(ptr unsafe.Pointer) interface{} { +func (type2 *safeType) PackEFace(ptr unsafe.Pointer) any { panic("does not support unsafe operation") } @@ -38,11 +38,11 @@ func (type2 *safeType) RType() uintptr { panic("does not support unsafe operation") } -func (type2 *safeType) Indirect(obj interface{}) interface{} { +func (type2 *safeType) Indirect(obj any) any { return reflect.Indirect(reflect.ValueOf(obj)).Interface() } -func (type2 *safeType) UnsafeIndirect(ptr unsafe.Pointer) interface{} { +func (type2 *safeType) UnsafeIndirect(ptr unsafe.Pointer) any { panic("does not support unsafe operation") } @@ -54,7 +54,7 @@ func (type2 *safeType) IsNullable() bool { return IsNullable(type2.Kind()) } -func (type2 *safeType) IsNil(obj interface{}) bool { +func (type2 *safeType) IsNil(obj any) bool { if obj == nil { return true } @@ -65,7 +65,7 @@ func (type2 *safeType) UnsafeIsNil(ptr unsafe.Pointer) bool { panic("does not support unsafe operation") } -func (type2 *safeType) Set(obj interface{}, val interface{}) { +func (type2 *safeType) Set(obj any, val any) { reflect.ValueOf(obj).Elem().Set(reflect.ValueOf(val).Elem()) } diff --git a/vendor/github.com/modern-go/reflect2/type_map.go b/vendor/github.com/modern-go/reflect2/type_map.go index 3acfb5580..a61ef5f41 100644 --- a/vendor/github.com/modern-go/reflect2/type_map.go +++ b/vendor/github.com/modern-go/reflect2/type_map.go @@ -9,10 +9,12 @@ import ( ) // typelinks1 for 1.5 ~ 1.6 +// //go:linkname typelinks1 reflect.typelinks func typelinks1() [][]unsafe.Pointer // typelinks2 for 1.7 ~ +// //go:linkname typelinks2 reflect.typelinks func typelinks2() (sections []unsafe.Pointer, offset [][]int32) @@ -38,7 +40,7 @@ func discoverTypes() { } func loadGo15Types() { - var obj interface{} = reflect.TypeOf(0) + var obj any = reflect.TypeOf(0) typePtrss := typelinks1() for _, typePtrs := range typePtrss { for _, typePtr := range typePtrs { @@ -70,7 +72,7 @@ func loadGo15Types() { } func loadGo17Types() { - var obj interface{} = reflect.TypeOf(0) + var obj any = reflect.TypeOf(0) sections, offset := typelinks2() for i, offs := range offset { rodata := sections[i] diff --git a/vendor/github.com/modern-go/reflect2/unsafe_array.go b/vendor/github.com/modern-go/reflect2/unsafe_array.go index 76cbdba6e..c847260d7 100644 --- a/vendor/github.com/modern-go/reflect2/unsafe_array.go +++ b/vendor/github.com/modern-go/reflect2/unsafe_array.go @@ -27,20 +27,20 @@ func (type2 *UnsafeArrayType) LikePtr() bool { return type2.likePtr } -func (type2 *UnsafeArrayType) Indirect(obj interface{}) interface{} { +func (type2 *UnsafeArrayType) Indirect(obj any) any { objEFace := unpackEFace(obj) assertType("Type.Indirect argument 1", type2.ptrRType, objEFace.rtype) return type2.UnsafeIndirect(objEFace.data) } -func (type2 *UnsafeArrayType) UnsafeIndirect(ptr unsafe.Pointer) interface{} { +func (type2 *UnsafeArrayType) UnsafeIndirect(ptr unsafe.Pointer) any { if type2.likePtr { return packEFace(type2.rtype, *(*unsafe.Pointer)(ptr)) } return packEFace(type2.rtype, ptr) } -func (type2 *UnsafeArrayType) SetIndex(obj interface{}, index int, elem interface{}) { +func (type2 *UnsafeArrayType) SetIndex(obj any, index int, elem any) { objEFace := unpackEFace(obj) assertType("ArrayType.SetIndex argument 1", type2.ptrRType, objEFace.rtype) elemEFace := unpackEFace(elem) @@ -53,7 +53,7 @@ func (type2 *UnsafeArrayType) UnsafeSetIndex(obj unsafe.Pointer, index int, elem typedmemmove(type2.elemRType, elemPtr, elem) } -func (type2 *UnsafeArrayType) GetIndex(obj interface{}, index int) interface{} { +func (type2 *UnsafeArrayType) GetIndex(obj any, index int) any { objEFace := unpackEFace(obj) assertType("ArrayType.GetIndex argument 1", type2.ptrRType, objEFace.rtype) elemPtr := type2.UnsafeGetIndex(objEFace.data, index) diff --git a/vendor/github.com/modern-go/reflect2/unsafe_eface.go b/vendor/github.com/modern-go/reflect2/unsafe_eface.go index 805010f3a..73b5e39ce 100644 --- a/vendor/github.com/modern-go/reflect2/unsafe_eface.go +++ b/vendor/github.com/modern-go/reflect2/unsafe_eface.go @@ -10,12 +10,12 @@ type eface struct { data unsafe.Pointer } -func unpackEFace(obj interface{}) *eface { +func unpackEFace(obj any) *eface { return (*eface)(unsafe.Pointer(&obj)) } -func packEFace(rtype unsafe.Pointer, data unsafe.Pointer) interface{} { - var i interface{} +func packEFace(rtype unsafe.Pointer, data unsafe.Pointer) any { + var i any e := (*eface)(unsafe.Pointer(&i)) e.rtype = rtype e.data = data @@ -32,7 +32,7 @@ func newUnsafeEFaceType(cfg *frozenConfig, type1 reflect.Type) *UnsafeEFaceType } } -func (type2 *UnsafeEFaceType) IsNil(obj interface{}) bool { +func (type2 *UnsafeEFaceType) IsNil(obj any) bool { if obj == nil { return true } @@ -45,15 +45,15 @@ func (type2 *UnsafeEFaceType) UnsafeIsNil(ptr unsafe.Pointer) bool { if ptr == nil { return true } - return unpackEFace(*(*interface{})(ptr)).data == nil + return unpackEFace(*(*any)(ptr)).data == nil } -func (type2 *UnsafeEFaceType) Indirect(obj interface{}) interface{} { +func (type2 *UnsafeEFaceType) Indirect(obj any) any { objEFace := unpackEFace(obj) assertType("Type.Indirect argument 1", type2.ptrRType, objEFace.rtype) return type2.UnsafeIndirect(objEFace.data) } -func (type2 *UnsafeEFaceType) UnsafeIndirect(ptr unsafe.Pointer) interface{} { - return *(*interface{})(ptr) +func (type2 *UnsafeEFaceType) UnsafeIndirect(ptr unsafe.Pointer) any { + return *(*any)(ptr) } diff --git a/vendor/github.com/modern-go/reflect2/unsafe_field.go b/vendor/github.com/modern-go/reflect2/unsafe_field.go index 5eb53130a..23db113be 100644 --- a/vendor/github.com/modern-go/reflect2/unsafe_field.go +++ b/vendor/github.com/modern-go/reflect2/unsafe_field.go @@ -49,7 +49,7 @@ func (field *UnsafeStructField) Anonymous() bool { return field.StructField.Anonymous } -func (field *UnsafeStructField) Set(obj interface{}, value interface{}) { +func (field *UnsafeStructField) Set(obj any, value any) { objEFace := unpackEFace(obj) assertType("StructField.SetIndex argument 1", field.structType.ptrRType, objEFace.rtype) valueEFace := unpackEFace(value) @@ -62,7 +62,7 @@ func (field *UnsafeStructField) UnsafeSet(obj unsafe.Pointer, value unsafe.Point typedmemmove(field.rtype, fieldPtr, value) } -func (field *UnsafeStructField) Get(obj interface{}) interface{} { +func (field *UnsafeStructField) Get(obj any) any { objEFace := unpackEFace(obj) assertType("StructField.GetIndex argument 1", field.structType.ptrRType, objEFace.rtype) value := field.UnsafeGet(objEFace.data) diff --git a/vendor/github.com/modern-go/reflect2/unsafe_iface.go b/vendor/github.com/modern-go/reflect2/unsafe_iface.go index b60195533..f4b2d650f 100644 --- a/vendor/github.com/modern-go/reflect2/unsafe_iface.go +++ b/vendor/github.com/modern-go/reflect2/unsafe_iface.go @@ -15,7 +15,7 @@ type itab struct { rtype unsafe.Pointer } -func IFaceToEFace(ptr unsafe.Pointer) interface{} { +func IFaceToEFace(ptr unsafe.Pointer) any { iface := (*iface)(ptr) if iface.itab == nil { return nil @@ -33,17 +33,17 @@ func newUnsafeIFaceType(cfg *frozenConfig, type1 reflect.Type) *UnsafeIFaceType } } -func (type2 *UnsafeIFaceType) Indirect(obj interface{}) interface{} { +func (type2 *UnsafeIFaceType) Indirect(obj any) any { objEFace := unpackEFace(obj) assertType("Type.Indirect argument 1", type2.ptrRType, objEFace.rtype) return type2.UnsafeIndirect(objEFace.data) } -func (type2 *UnsafeIFaceType) UnsafeIndirect(ptr unsafe.Pointer) interface{} { +func (type2 *UnsafeIFaceType) UnsafeIndirect(ptr unsafe.Pointer) any { return IFaceToEFace(ptr) } -func (type2 *UnsafeIFaceType) IsNil(obj interface{}) bool { +func (type2 *UnsafeIFaceType) IsNil(obj any) bool { if obj == nil { return true } diff --git a/vendor/github.com/modern-go/reflect2/unsafe_link.go b/vendor/github.com/modern-go/reflect2/unsafe_link.go index 57229c8db..674c18fc6 100644 --- a/vendor/github.com/modern-go/reflect2/unsafe_link.go +++ b/vendor/github.com/modern-go/reflect2/unsafe_link.go @@ -13,6 +13,7 @@ func unsafe_NewArray(rtype unsafe.Pointer, length int) unsafe.Pointer // typedslicecopy copies a slice of elemType values from src to dst, // returning the number of elements copied. +// //go:linkname typedslicecopy reflect.typedslicecopy //go:noescape func typedslicecopy(elemType unsafe.Pointer, dst, src sliceHeader) int @@ -27,6 +28,7 @@ func mapaccess(rtype unsafe.Pointer, m unsafe.Pointer, key unsafe.Pointer) (val // m escapes into the return value, but the caller of mapiterinit // doesn't let the return value escape. +// //go:noescape //go:linkname mapiterinit reflect.mapiterinit func mapiterinit(rtype unsafe.Pointer, m unsafe.Pointer) *hiter @@ -36,7 +38,7 @@ func mapiterinit(rtype unsafe.Pointer, m unsafe.Pointer) *hiter func mapiternext(it *hiter) //go:linkname ifaceE2I reflect.ifaceE2I -func ifaceE2I(rtype unsafe.Pointer, src interface{}, dst unsafe.Pointer) +func ifaceE2I(rtype unsafe.Pointer, src any, dst unsafe.Pointer) // A hash iteration structure. // If you modify hiter, also change cmd/internal/gc/reflect.go to indicate diff --git a/vendor/github.com/modern-go/reflect2/unsafe_map.go b/vendor/github.com/modern-go/reflect2/unsafe_map.go index f2e76e6bb..29f8a8039 100644 --- a/vendor/github.com/modern-go/reflect2/unsafe_map.go +++ b/vendor/github.com/modern-go/reflect2/unsafe_map.go @@ -19,7 +19,7 @@ func newUnsafeMapType(cfg *frozenConfig, type1 reflect.Type) MapType { } } -func (type2 *UnsafeMapType) IsNil(obj interface{}) bool { +func (type2 *UnsafeMapType) IsNil(obj any) bool { if obj == nil { return true } @@ -39,13 +39,13 @@ func (type2 *UnsafeMapType) LikePtr() bool { return true } -func (type2 *UnsafeMapType) Indirect(obj interface{}) interface{} { +func (type2 *UnsafeMapType) Indirect(obj any) any { objEFace := unpackEFace(obj) assertType("MapType.Indirect argument 1", type2.ptrRType, objEFace.rtype) return type2.UnsafeIndirect(objEFace.data) } -func (type2 *UnsafeMapType) UnsafeIndirect(ptr unsafe.Pointer) interface{} { +func (type2 *UnsafeMapType) UnsafeIndirect(ptr unsafe.Pointer) any { return packEFace(type2.rtype, *(*unsafe.Pointer)(ptr)) } @@ -53,7 +53,7 @@ func (type2 *UnsafeMapType) Key() Type { return type2.cfg.Type2(type2.Type.Key()) } -func (type2 *UnsafeMapType) MakeMap(cap int) interface{} { +func (type2 *UnsafeMapType) MakeMap(cap int) any { return packEFace(type2.ptrRType, type2.UnsafeMakeMap(cap)) } @@ -62,7 +62,7 @@ func (type2 *UnsafeMapType) UnsafeMakeMap(cap int) unsafe.Pointer { return unsafe.Pointer(&m) } -func (type2 *UnsafeMapType) SetIndex(obj interface{}, key interface{}, elem interface{}) { +func (type2 *UnsafeMapType) SetIndex(obj any, key any, elem any) { objEFace := unpackEFace(obj) assertType("MapType.SetIndex argument 1", type2.ptrRType, objEFace.rtype) keyEFace := unpackEFace(key) @@ -76,7 +76,7 @@ func (type2 *UnsafeMapType) UnsafeSetIndex(obj unsafe.Pointer, key unsafe.Pointe mapassign(type2.rtype, *(*unsafe.Pointer)(obj), key, elem) } -func (type2 *UnsafeMapType) TryGetIndex(obj interface{}, key interface{}) (interface{}, bool) { +func (type2 *UnsafeMapType) TryGetIndex(obj any, key any) (any, bool) { objEFace := unpackEFace(obj) assertType("MapType.TryGetIndex argument 1", type2.ptrRType, objEFace.rtype) keyEFace := unpackEFace(key) @@ -88,7 +88,7 @@ func (type2 *UnsafeMapType) TryGetIndex(obj interface{}, key interface{}) (inter return packEFace(type2.pElemRType, elemPtr), true } -func (type2 *UnsafeMapType) GetIndex(obj interface{}, key interface{}) interface{} { +func (type2 *UnsafeMapType) GetIndex(obj any, key any) any { objEFace := unpackEFace(obj) assertType("MapType.GetIndex argument 1", type2.ptrRType, objEFace.rtype) keyEFace := unpackEFace(key) @@ -101,7 +101,7 @@ func (type2 *UnsafeMapType) UnsafeGetIndex(obj unsafe.Pointer, key unsafe.Pointe return mapaccess(type2.rtype, *(*unsafe.Pointer)(obj), key) } -func (type2 *UnsafeMapType) Iterate(obj interface{}) MapIterator { +func (type2 *UnsafeMapType) Iterate(obj any) MapIterator { objEFace := unpackEFace(obj) assertType("MapType.Iterate argument 1", type2.ptrRType, objEFace.rtype) return type2.UnsafeIterate(objEFace.data) @@ -125,7 +125,7 @@ func (iter *UnsafeMapIterator) HasNext() bool { return iter.key != nil } -func (iter *UnsafeMapIterator) Next() (interface{}, interface{}) { +func (iter *UnsafeMapIterator) Next() (any, any) { key, elem := iter.UnsafeNext() return packEFace(iter.pKeyRType, key), packEFace(iter.pElemRType, elem) } diff --git a/vendor/github.com/modern-go/reflect2/unsafe_ptr.go b/vendor/github.com/modern-go/reflect2/unsafe_ptr.go index 8e5ec9cf4..ab7f409b0 100644 --- a/vendor/github.com/modern-go/reflect2/unsafe_ptr.go +++ b/vendor/github.com/modern-go/reflect2/unsafe_ptr.go @@ -15,7 +15,7 @@ func newUnsafePtrType(cfg *frozenConfig, type1 reflect.Type) *UnsafePtrType { } } -func (type2 *UnsafePtrType) IsNil(obj interface{}) bool { +func (type2 *UnsafePtrType) IsNil(obj any) bool { if obj == nil { return true } @@ -35,12 +35,12 @@ func (type2 *UnsafePtrType) LikePtr() bool { return true } -func (type2 *UnsafePtrType) Indirect(obj interface{}) interface{} { +func (type2 *UnsafePtrType) Indirect(obj any) any { objEFace := unpackEFace(obj) assertType("Type.Indirect argument 1", type2.ptrRType, objEFace.rtype) return type2.UnsafeIndirect(objEFace.data) } -func (type2 *UnsafePtrType) UnsafeIndirect(ptr unsafe.Pointer) interface{} { +func (type2 *UnsafePtrType) UnsafeIndirect(ptr unsafe.Pointer) any { return packEFace(type2.rtype, *(*unsafe.Pointer)(ptr)) } diff --git a/vendor/github.com/modern-go/reflect2/unsafe_slice.go b/vendor/github.com/modern-go/reflect2/unsafe_slice.go index 1c6d876c7..06a36ede6 100644 --- a/vendor/github.com/modern-go/reflect2/unsafe_slice.go +++ b/vendor/github.com/modern-go/reflect2/unsafe_slice.go @@ -29,7 +29,7 @@ func newUnsafeSliceType(cfg *frozenConfig, type1 reflect.Type) SliceType { } } -func (type2 *UnsafeSliceType) Set(obj interface{}, val interface{}) { +func (type2 *UnsafeSliceType) Set(obj any, val any) { objEFace := unpackEFace(obj) assertType("Type.Set argument 1", type2.ptrRType, objEFace.rtype) valEFace := unpackEFace(val) @@ -41,7 +41,7 @@ func (type2 *UnsafeSliceType) UnsafeSet(ptr unsafe.Pointer, val unsafe.Pointer) *(*sliceHeader)(ptr) = *(*sliceHeader)(val) } -func (type2 *UnsafeSliceType) IsNil(obj interface{}) bool { +func (type2 *UnsafeSliceType) IsNil(obj any) bool { if obj == nil { return true } @@ -57,7 +57,7 @@ func (type2 *UnsafeSliceType) UnsafeIsNil(ptr unsafe.Pointer) bool { return (*sliceHeader)(ptr).Data == nil } -func (type2 *UnsafeSliceType) SetNil(obj interface{}) { +func (type2 *UnsafeSliceType) SetNil(obj any) { objEFace := unpackEFace(obj) assertType("SliceType.SetNil argument 1", type2.ptrRType, objEFace.rtype) type2.UnsafeSetNil(objEFace.data) @@ -70,7 +70,7 @@ func (type2 *UnsafeSliceType) UnsafeSetNil(ptr unsafe.Pointer) { header.Data = nil } -func (type2 *UnsafeSliceType) MakeSlice(length int, cap int) interface{} { +func (type2 *UnsafeSliceType) MakeSlice(length int, cap int) any { return packEFace(type2.ptrRType, type2.UnsafeMakeSlice(length, cap)) } @@ -79,7 +79,7 @@ func (type2 *UnsafeSliceType) UnsafeMakeSlice(length int, cap int) unsafe.Pointe return unsafe.Pointer(header) } -func (type2 *UnsafeSliceType) LengthOf(obj interface{}) int { +func (type2 *UnsafeSliceType) LengthOf(obj any) int { objEFace := unpackEFace(obj) assertType("SliceType.Len argument 1", type2.ptrRType, objEFace.rtype) return type2.UnsafeLengthOf(objEFace.data) @@ -90,7 +90,7 @@ func (type2 *UnsafeSliceType) UnsafeLengthOf(obj unsafe.Pointer) int { return header.Len } -func (type2 *UnsafeSliceType) SetIndex(obj interface{}, index int, elem interface{}) { +func (type2 *UnsafeSliceType) SetIndex(obj any, index int, elem any) { objEFace := unpackEFace(obj) assertType("SliceType.SetIndex argument 1", type2.ptrRType, objEFace.rtype) elemEFace := unpackEFace(elem) @@ -104,7 +104,7 @@ func (type2 *UnsafeSliceType) UnsafeSetIndex(obj unsafe.Pointer, index int, elem typedmemmove(type2.elemRType, elemPtr, elem) } -func (type2 *UnsafeSliceType) GetIndex(obj interface{}, index int) interface{} { +func (type2 *UnsafeSliceType) GetIndex(obj any, index int) any { objEFace := unpackEFace(obj) assertType("SliceType.GetIndex argument 1", type2.ptrRType, objEFace.rtype) elemPtr := type2.UnsafeGetIndex(objEFace.data, index) @@ -116,7 +116,7 @@ func (type2 *UnsafeSliceType) UnsafeGetIndex(obj unsafe.Pointer, index int) unsa return arrayAt(header.Data, index, type2.elemSize, "i < s.Len") } -func (type2 *UnsafeSliceType) Append(obj interface{}, elem interface{}) { +func (type2 *UnsafeSliceType) Append(obj any, elem any) { objEFace := unpackEFace(obj) assertType("SliceType.Append argument 1", type2.ptrRType, objEFace.rtype) elemEFace := unpackEFace(elem) @@ -131,7 +131,7 @@ func (type2 *UnsafeSliceType) UnsafeAppend(obj unsafe.Pointer, elem unsafe.Point type2.UnsafeSetIndex(obj, oldLen, elem) } -func (type2 *UnsafeSliceType) Cap(obj interface{}) int { +func (type2 *UnsafeSliceType) Cap(obj any) int { objEFace := unpackEFace(obj) assertType("SliceType.Cap argument 1", type2.ptrRType, objEFace.rtype) return type2.UnsafeCap(objEFace.data) @@ -141,7 +141,7 @@ func (type2 *UnsafeSliceType) UnsafeCap(ptr unsafe.Pointer) int { return (*sliceHeader)(ptr).Cap } -func (type2 *UnsafeSliceType) Grow(obj interface{}, newLength int) { +func (type2 *UnsafeSliceType) Grow(obj any, newLength int) { objEFace := unpackEFace(obj) assertType("SliceType.Grow argument 1", type2.ptrRType, objEFace.rtype) type2.UnsafeGrow(objEFace.data, newLength) diff --git a/vendor/github.com/modern-go/reflect2/unsafe_struct.go b/vendor/github.com/modern-go/reflect2/unsafe_struct.go index 804d91663..dc8217012 100644 --- a/vendor/github.com/modern-go/reflect2/unsafe_struct.go +++ b/vendor/github.com/modern-go/reflect2/unsafe_struct.go @@ -21,13 +21,13 @@ func (type2 *UnsafeStructType) LikePtr() bool { return type2.likePtr } -func (type2 *UnsafeStructType) Indirect(obj interface{}) interface{} { +func (type2 *UnsafeStructType) Indirect(obj any) any { objEFace := unpackEFace(obj) assertType("Type.Indirect argument 1", type2.ptrRType, objEFace.rtype) return type2.UnsafeIndirect(objEFace.data) } -func (type2 *UnsafeStructType) UnsafeIndirect(ptr unsafe.Pointer) interface{} { +func (type2 *UnsafeStructType) UnsafeIndirect(ptr unsafe.Pointer) any { if type2.likePtr { return packEFace(type2.rtype, *(*unsafe.Pointer)(ptr)) } diff --git a/vendor/github.com/modern-go/reflect2/unsafe_type.go b/vendor/github.com/modern-go/reflect2/unsafe_type.go index 13941716c..79fafa672 100644 --- a/vendor/github.com/modern-go/reflect2/unsafe_type.go +++ b/vendor/github.com/modern-go/reflect2/unsafe_type.go @@ -22,7 +22,7 @@ func newUnsafeType(cfg *frozenConfig, type1 reflect.Type) *unsafeType { } } -func (type2 *unsafeType) Set(obj interface{}, val interface{}) { +func (type2 *unsafeType) Set(obj any, val any) { objEFace := unpackEFace(obj) assertType("Type.Set argument 1", type2.ptrRType, objEFace.rtype) valEFace := unpackEFace(val) @@ -34,7 +34,7 @@ func (type2 *unsafeType) UnsafeSet(ptr unsafe.Pointer, val unsafe.Pointer) { typedmemmove(type2.rtype, ptr, val) } -func (type2 *unsafeType) IsNil(obj interface{}) bool { +func (type2 *unsafeType) IsNil(obj any) bool { objEFace := unpackEFace(obj) assertType("Type.IsNil argument 1", type2.ptrRType, objEFace.rtype) return type2.UnsafeIsNil(objEFace.data) @@ -48,11 +48,11 @@ func (type2 *unsafeType) UnsafeNew() unsafe.Pointer { return unsafe_New(type2.rtype) } -func (type2 *unsafeType) New() interface{} { +func (type2 *unsafeType) New() any { return packEFace(type2.ptrRType, type2.UnsafeNew()) } -func (type2 *unsafeType) PackEFace(ptr unsafe.Pointer) interface{} { +func (type2 *unsafeType) PackEFace(ptr unsafe.Pointer) any { return packEFace(type2.ptrRType, ptr) } @@ -60,13 +60,13 @@ func (type2 *unsafeType) RType() uintptr { return uintptr(type2.rtype) } -func (type2 *unsafeType) Indirect(obj interface{}) interface{} { +func (type2 *unsafeType) Indirect(obj any) any { objEFace := unpackEFace(obj) assertType("Type.Indirect argument 1", type2.ptrRType, objEFace.rtype) return type2.UnsafeIndirect(objEFace.data) } -func (type2 *unsafeType) UnsafeIndirect(obj unsafe.Pointer) interface{} { +func (type2 *unsafeType) UnsafeIndirect(obj unsafe.Pointer) any { return packEFace(type2.rtype, obj) } diff --git a/vendor/github.com/prometheus/client_golang/prometheus/expvar_collector.go b/vendor/github.com/prometheus/client_golang/prometheus/expvar_collector.go index 18a99d5fa..1737a2c3a 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/expvar_collector.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/expvar_collector.go @@ -80,14 +80,14 @@ func (e *expvarCollector) Collect(ch chan<- Metric) { if expVar == nil { continue } - var v interface{} + var v any labels := make([]string, len(desc.variableLabels)) if err := json.Unmarshal([]byte(expVar.String()), &v); err != nil { ch <- NewInvalidMetric(desc, err) continue } - var processValue func(v interface{}, i int) - processValue = func(v interface{}, i int) { + var processValue func(v any, i int) + processValue = func(v any, i int) { if i >= len(labels) { copiedLabels := append(make([]string, 0, len(labels)), labels...) switch v := v.(type) { @@ -105,7 +105,7 @@ func (e *expvarCollector) Collect(ch chan<- Metric) { ch <- m return } - vm, ok := v.(map[string]interface{}) + vm, ok := v.(map[string]any) if !ok { return } diff --git a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go index cea5a90fd..df466b0ca 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go @@ -52,7 +52,7 @@ const ( ) var gzipPool = sync.Pool{ - New: func() interface{} { + New: func() any { return gzip.NewWriter(nil) }, } @@ -275,7 +275,7 @@ const ( // log.Logger from the standard library implements this interface, and it is // easy to implement by custom loggers, if they don't do so already anyway. type Logger interface { - Println(v ...interface{}) + Println(v ...any) } // HandlerOpts specifies options how to serve metrics via an http.Handler. The diff --git a/vendor/github.com/prometheus/common/expfmt/text_create.go b/vendor/github.com/prometheus/common/expfmt/text_create.go index 8e473d0fe..5fc4da4ff 100644 --- a/vendor/github.com/prometheus/common/expfmt/text_create.go +++ b/vendor/github.com/prometheus/common/expfmt/text_create.go @@ -43,12 +43,12 @@ const ( var ( bufPool = sync.Pool{ - New: func() interface{} { + New: func() any { return bytes.NewBuffer(make([]byte, 0, initialBufSize)) }, } numBufPool = sync.Pool{ - New: func() interface{} { + New: func() any { b := make([]byte, 0, initialNumBufSize) return &b }, diff --git a/vendor/github.com/prometheus/common/model/labels.go b/vendor/github.com/prometheus/common/model/labels.go index 41051a01a..d83cb9e31 100644 --- a/vendor/github.com/prometheus/common/model/labels.go +++ b/vendor/github.com/prometheus/common/model/labels.go @@ -105,7 +105,7 @@ func (ln LabelName) IsValid() bool { } // UnmarshalYAML implements the yaml.Unmarshaler interface. -func (ln *LabelName) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (ln *LabelName) UnmarshalYAML(unmarshal func(any) error) error { var s string if err := unmarshal(&s); err != nil { return err diff --git a/vendor/github.com/prometheus/common/model/time.go b/vendor/github.com/prometheus/common/model/time.go index 7b0064fdb..388f4719d 100644 --- a/vendor/github.com/prometheus/common/model/time.go +++ b/vendor/github.com/prometheus/common/model/time.go @@ -251,12 +251,12 @@ func (d Duration) String() string { } // MarshalYAML implements the yaml.Marshaler interface. -func (d Duration) MarshalYAML() (interface{}, error) { +func (d Duration) MarshalYAML() (any, error) { return d.String(), nil } // UnmarshalYAML implements the yaml.Unmarshaler interface. -func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (d *Duration) UnmarshalYAML(unmarshal func(any) error) error { var s string if err := unmarshal(&s); err != nil { return err diff --git a/vendor/github.com/prometheus/common/model/value.go b/vendor/github.com/prometheus/common/model/value.go index c9d8fb1a2..51c0ed0c3 100644 --- a/vendor/github.com/prometheus/common/model/value.go +++ b/vendor/github.com/prometheus/common/model/value.go @@ -310,13 +310,13 @@ func (s Scalar) String() string { // MarshalJSON implements json.Marshaler. func (s Scalar) MarshalJSON() ([]byte, error) { v := strconv.FormatFloat(float64(s.Value), 'f', -1, 64) - return json.Marshal([...]interface{}{s.Timestamp, string(v)}) + return json.Marshal([...]any{s.Timestamp, string(v)}) } // UnmarshalJSON implements json.Unmarshaler. func (s *Scalar) UnmarshalJSON(b []byte) error { var f string - v := [...]interface{}{&s.Timestamp, &f} + v := [...]any{&s.Timestamp, &f} if err := json.Unmarshal(b, &v); err != nil { return err @@ -342,12 +342,12 @@ func (s *String) String() string { // MarshalJSON implements json.Marshaler. func (s String) MarshalJSON() ([]byte, error) { - return json.Marshal([]interface{}{s.Timestamp, s.Value}) + return json.Marshal([]any{s.Timestamp, s.Value}) } // UnmarshalJSON implements json.Unmarshaler. func (s *String) UnmarshalJSON(b []byte) error { - v := [...]interface{}{&s.Timestamp, &s.Value} + v := [...]any{&s.Timestamp, &s.Value} return json.Unmarshal(b, &v) } diff --git a/vendor/github.com/sirupsen/logrus/entry.go b/vendor/github.com/sirupsen/logrus/entry.go index 63e25583c..f46624237 100644 --- a/vendor/github.com/sirupsen/logrus/entry.go +++ b/vendor/github.com/sirupsen/logrus/entry.go @@ -32,7 +32,7 @@ const ( func init() { bufferPool = &sync.Pool{ - New: func() interface{} { + New: func() any { return new(bytes.Buffer) }, } @@ -107,7 +107,7 @@ func (entry *Entry) WithContext(ctx context.Context) *Entry { } // Add a single field to the Entry. -func (entry *Entry) WithField(key string, value interface{}) *Entry { +func (entry *Entry) WithField(key string, value any) *Entry { return entry.WithFields(Fields{key: value}) } @@ -263,137 +263,137 @@ func (entry *Entry) write() { } } -func (entry *Entry) Log(level Level, args ...interface{}) { +func (entry *Entry) Log(level Level, args ...any) { if entry.Logger.IsLevelEnabled(level) { entry.log(level, fmt.Sprint(args...)) } } -func (entry *Entry) Trace(args ...interface{}) { +func (entry *Entry) Trace(args ...any) { entry.Log(TraceLevel, args...) } -func (entry *Entry) Debug(args ...interface{}) { +func (entry *Entry) Debug(args ...any) { entry.Log(DebugLevel, args...) } -func (entry *Entry) Print(args ...interface{}) { +func (entry *Entry) Print(args ...any) { entry.Info(args...) } -func (entry *Entry) Info(args ...interface{}) { +func (entry *Entry) Info(args ...any) { entry.Log(InfoLevel, args...) } -func (entry *Entry) Warn(args ...interface{}) { +func (entry *Entry) Warn(args ...any) { entry.Log(WarnLevel, args...) } -func (entry *Entry) Warning(args ...interface{}) { +func (entry *Entry) Warning(args ...any) { entry.Warn(args...) } -func (entry *Entry) Error(args ...interface{}) { +func (entry *Entry) Error(args ...any) { entry.Log(ErrorLevel, args...) } -func (entry *Entry) Fatal(args ...interface{}) { +func (entry *Entry) Fatal(args ...any) { entry.Log(FatalLevel, args...) entry.Logger.Exit(1) } -func (entry *Entry) Panic(args ...interface{}) { +func (entry *Entry) Panic(args ...any) { entry.Log(PanicLevel, args...) panic(fmt.Sprint(args...)) } // Entry Printf family functions -func (entry *Entry) Logf(level Level, format string, args ...interface{}) { +func (entry *Entry) Logf(level Level, format string, args ...any) { if entry.Logger.IsLevelEnabled(level) { entry.Log(level, fmt.Sprintf(format, args...)) } } -func (entry *Entry) Tracef(format string, args ...interface{}) { +func (entry *Entry) Tracef(format string, args ...any) { entry.Logf(TraceLevel, format, args...) } -func (entry *Entry) Debugf(format string, args ...interface{}) { +func (entry *Entry) Debugf(format string, args ...any) { entry.Logf(DebugLevel, format, args...) } -func (entry *Entry) Infof(format string, args ...interface{}) { +func (entry *Entry) Infof(format string, args ...any) { entry.Logf(InfoLevel, format, args...) } -func (entry *Entry) Printf(format string, args ...interface{}) { +func (entry *Entry) Printf(format string, args ...any) { entry.Infof(format, args...) } -func (entry *Entry) Warnf(format string, args ...interface{}) { +func (entry *Entry) Warnf(format string, args ...any) { entry.Logf(WarnLevel, format, args...) } -func (entry *Entry) Warningf(format string, args ...interface{}) { +func (entry *Entry) Warningf(format string, args ...any) { entry.Warnf(format, args...) } -func (entry *Entry) Errorf(format string, args ...interface{}) { +func (entry *Entry) Errorf(format string, args ...any) { entry.Logf(ErrorLevel, format, args...) } -func (entry *Entry) Fatalf(format string, args ...interface{}) { +func (entry *Entry) Fatalf(format string, args ...any) { entry.Logf(FatalLevel, format, args...) entry.Logger.Exit(1) } -func (entry *Entry) Panicf(format string, args ...interface{}) { +func (entry *Entry) Panicf(format string, args ...any) { entry.Logf(PanicLevel, format, args...) } // Entry Println family functions -func (entry *Entry) Logln(level Level, args ...interface{}) { +func (entry *Entry) Logln(level Level, args ...any) { if entry.Logger.IsLevelEnabled(level) { entry.Log(level, entry.sprintlnn(args...)) } } -func (entry *Entry) Traceln(args ...interface{}) { +func (entry *Entry) Traceln(args ...any) { entry.Logln(TraceLevel, args...) } -func (entry *Entry) Debugln(args ...interface{}) { +func (entry *Entry) Debugln(args ...any) { entry.Logln(DebugLevel, args...) } -func (entry *Entry) Infoln(args ...interface{}) { +func (entry *Entry) Infoln(args ...any) { entry.Logln(InfoLevel, args...) } -func (entry *Entry) Println(args ...interface{}) { +func (entry *Entry) Println(args ...any) { entry.Infoln(args...) } -func (entry *Entry) Warnln(args ...interface{}) { +func (entry *Entry) Warnln(args ...any) { entry.Logln(WarnLevel, args...) } -func (entry *Entry) Warningln(args ...interface{}) { +func (entry *Entry) Warningln(args ...any) { entry.Warnln(args...) } -func (entry *Entry) Errorln(args ...interface{}) { +func (entry *Entry) Errorln(args ...any) { entry.Logln(ErrorLevel, args...) } -func (entry *Entry) Fatalln(args ...interface{}) { +func (entry *Entry) Fatalln(args ...any) { entry.Logln(FatalLevel, args...) entry.Logger.Exit(1) } -func (entry *Entry) Panicln(args ...interface{}) { +func (entry *Entry) Panicln(args ...any) { entry.Logln(PanicLevel, args...) } @@ -401,7 +401,7 @@ func (entry *Entry) Panicln(args ...interface{}) { // fmt.Sprintln where spaces are always added between operands, regardless of // their type. Instead of vendoring the Sprintln implementation to spare a // string allocation, we do the simplest thing. -func (entry *Entry) sprintlnn(args ...interface{}) string { +func (entry *Entry) sprintlnn(args ...any) string { msg := fmt.Sprintln(args...) return msg[:len(msg)-1] } diff --git a/vendor/github.com/sirupsen/logrus/exported.go b/vendor/github.com/sirupsen/logrus/exported.go index 62fc2f219..1a678f3d4 100644 --- a/vendor/github.com/sirupsen/logrus/exported.go +++ b/vendor/github.com/sirupsen/logrus/exported.go @@ -66,7 +66,7 @@ func WithContext(ctx context.Context) *Entry { // // Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal // or Panic on the Entry it returns. -func WithField(key string, value interface{}) *Entry { +func WithField(key string, value any) *Entry { return std.WithField(key, value) } @@ -90,136 +90,136 @@ func WithTime(t time.Time) *Entry { } // Trace logs a message at level Trace on the standard logger. -func Trace(args ...interface{}) { +func Trace(args ...any) { std.Trace(args...) } // Debug logs a message at level Debug on the standard logger. -func Debug(args ...interface{}) { +func Debug(args ...any) { std.Debug(args...) } // Print logs a message at level Info on the standard logger. -func Print(args ...interface{}) { +func Print(args ...any) { std.Print(args...) } // Info logs a message at level Info on the standard logger. -func Info(args ...interface{}) { +func Info(args ...any) { std.Info(args...) } // Warn logs a message at level Warn on the standard logger. -func Warn(args ...interface{}) { +func Warn(args ...any) { std.Warn(args...) } // Warning logs a message at level Warn on the standard logger. -func Warning(args ...interface{}) { +func Warning(args ...any) { std.Warning(args...) } // Error logs a message at level Error on the standard logger. -func Error(args ...interface{}) { +func Error(args ...any) { std.Error(args...) } // Panic logs a message at level Panic on the standard logger. -func Panic(args ...interface{}) { +func Panic(args ...any) { std.Panic(args...) } // Fatal logs a message at level Fatal on the standard logger then the process will exit with status set to 1. -func Fatal(args ...interface{}) { +func Fatal(args ...any) { std.Fatal(args...) } // Tracef logs a message at level Trace on the standard logger. -func Tracef(format string, args ...interface{}) { +func Tracef(format string, args ...any) { std.Tracef(format, args...) } // Debugf logs a message at level Debug on the standard logger. -func Debugf(format string, args ...interface{}) { +func Debugf(format string, args ...any) { std.Debugf(format, args...) } // Printf logs a message at level Info on the standard logger. -func Printf(format string, args ...interface{}) { +func Printf(format string, args ...any) { std.Printf(format, args...) } // Infof logs a message at level Info on the standard logger. -func Infof(format string, args ...interface{}) { +func Infof(format string, args ...any) { std.Infof(format, args...) } // Warnf logs a message at level Warn on the standard logger. -func Warnf(format string, args ...interface{}) { +func Warnf(format string, args ...any) { std.Warnf(format, args...) } // Warningf logs a message at level Warn on the standard logger. -func Warningf(format string, args ...interface{}) { +func Warningf(format string, args ...any) { std.Warningf(format, args...) } // Errorf logs a message at level Error on the standard logger. -func Errorf(format string, args ...interface{}) { +func Errorf(format string, args ...any) { std.Errorf(format, args...) } // Panicf logs a message at level Panic on the standard logger. -func Panicf(format string, args ...interface{}) { +func Panicf(format string, args ...any) { std.Panicf(format, args...) } // Fatalf logs a message at level Fatal on the standard logger then the process will exit with status set to 1. -func Fatalf(format string, args ...interface{}) { +func Fatalf(format string, args ...any) { std.Fatalf(format, args...) } // Traceln logs a message at level Trace on the standard logger. -func Traceln(args ...interface{}) { +func Traceln(args ...any) { std.Traceln(args...) } // Debugln logs a message at level Debug on the standard logger. -func Debugln(args ...interface{}) { +func Debugln(args ...any) { std.Debugln(args...) } // Println logs a message at level Info on the standard logger. -func Println(args ...interface{}) { +func Println(args ...any) { std.Println(args...) } // Infoln logs a message at level Info on the standard logger. -func Infoln(args ...interface{}) { +func Infoln(args ...any) { std.Infoln(args...) } // Warnln logs a message at level Warn on the standard logger. -func Warnln(args ...interface{}) { +func Warnln(args ...any) { std.Warnln(args...) } // Warningln logs a message at level Warn on the standard logger. -func Warningln(args ...interface{}) { +func Warningln(args ...any) { std.Warningln(args...) } // Errorln logs a message at level Error on the standard logger. -func Errorln(args ...interface{}) { +func Errorln(args ...any) { std.Errorln(args...) } // Panicln logs a message at level Panic on the standard logger. -func Panicln(args ...interface{}) { +func Panicln(args ...any) { std.Panicln(args...) } // Fatalln logs a message at level Fatal on the standard logger then the process will exit with status set to 1. -func Fatalln(args ...interface{}) { +func Fatalln(args ...any) { std.Fatalln(args...) } diff --git a/vendor/github.com/sirupsen/logrus/logger.go b/vendor/github.com/sirupsen/logrus/logger.go index c0c0b1e55..97655ef22 100644 --- a/vendor/github.com/sirupsen/logrus/logger.go +++ b/vendor/github.com/sirupsen/logrus/logger.go @@ -68,12 +68,12 @@ func (mw *MutexWrap) Disable() { // `Out` and `Hooks` directly on the default logger instance. You can also just // instantiate your own: // -// var log = &Logger{ -// Out: os.Stderr, -// Formatter: new(JSONFormatter), -// Hooks: make(LevelHooks), -// Level: logrus.DebugLevel, -// } +// var log = &Logger{ +// Out: os.Stderr, +// Formatter: new(JSONFormatter), +// Hooks: make(LevelHooks), +// Level: logrus.DebugLevel, +// } // // It's recommended to make this a global instance called `log`. func New() *Logger { @@ -96,14 +96,14 @@ func (logger *Logger) newEntry() *Entry { } func (logger *Logger) releaseEntry(entry *Entry) { - entry.Data = map[string]interface{}{} + entry.Data = map[string]any{} logger.entryPool.Put(entry) } // Adds a field to the log entry, note that it doesn't log until you call // Debug, Print, Info, Warn, Error, Fatal or Panic. It only creates a log entry. // If you want multiple fields, use `WithFields`. -func (logger *Logger) WithField(key string, value interface{}) *Entry { +func (logger *Logger) WithField(key string, value any) *Entry { entry := logger.newEntry() defer logger.releaseEntry(entry) return entry.WithField(key, value) @@ -139,7 +139,7 @@ func (logger *Logger) WithTime(t time.Time) *Entry { return entry.WithTime(t) } -func (logger *Logger) Logf(level Level, format string, args ...interface{}) { +func (logger *Logger) Logf(level Level, format string, args ...any) { if logger.IsLevelEnabled(level) { entry := logger.newEntry() entry.Logf(level, format, args...) @@ -147,46 +147,46 @@ func (logger *Logger) Logf(level Level, format string, args ...interface{}) { } } -func (logger *Logger) Tracef(format string, args ...interface{}) { +func (logger *Logger) Tracef(format string, args ...any) { logger.Logf(TraceLevel, format, args...) } -func (logger *Logger) Debugf(format string, args ...interface{}) { +func (logger *Logger) Debugf(format string, args ...any) { logger.Logf(DebugLevel, format, args...) } -func (logger *Logger) Infof(format string, args ...interface{}) { +func (logger *Logger) Infof(format string, args ...any) { logger.Logf(InfoLevel, format, args...) } -func (logger *Logger) Printf(format string, args ...interface{}) { +func (logger *Logger) Printf(format string, args ...any) { entry := logger.newEntry() entry.Printf(format, args...) logger.releaseEntry(entry) } -func (logger *Logger) Warnf(format string, args ...interface{}) { +func (logger *Logger) Warnf(format string, args ...any) { logger.Logf(WarnLevel, format, args...) } -func (logger *Logger) Warningf(format string, args ...interface{}) { +func (logger *Logger) Warningf(format string, args ...any) { logger.Warnf(format, args...) } -func (logger *Logger) Errorf(format string, args ...interface{}) { +func (logger *Logger) Errorf(format string, args ...any) { logger.Logf(ErrorLevel, format, args...) } -func (logger *Logger) Fatalf(format string, args ...interface{}) { +func (logger *Logger) Fatalf(format string, args ...any) { logger.Logf(FatalLevel, format, args...) logger.Exit(1) } -func (logger *Logger) Panicf(format string, args ...interface{}) { +func (logger *Logger) Panicf(format string, args ...any) { logger.Logf(PanicLevel, format, args...) } -func (logger *Logger) Log(level Level, args ...interface{}) { +func (logger *Logger) Log(level Level, args ...any) { if logger.IsLevelEnabled(level) { entry := logger.newEntry() entry.Log(level, args...) @@ -194,46 +194,46 @@ func (logger *Logger) Log(level Level, args ...interface{}) { } } -func (logger *Logger) Trace(args ...interface{}) { +func (logger *Logger) Trace(args ...any) { logger.Log(TraceLevel, args...) } -func (logger *Logger) Debug(args ...interface{}) { +func (logger *Logger) Debug(args ...any) { logger.Log(DebugLevel, args...) } -func (logger *Logger) Info(args ...interface{}) { +func (logger *Logger) Info(args ...any) { logger.Log(InfoLevel, args...) } -func (logger *Logger) Print(args ...interface{}) { +func (logger *Logger) Print(args ...any) { entry := logger.newEntry() entry.Print(args...) logger.releaseEntry(entry) } -func (logger *Logger) Warn(args ...interface{}) { +func (logger *Logger) Warn(args ...any) { logger.Log(WarnLevel, args...) } -func (logger *Logger) Warning(args ...interface{}) { +func (logger *Logger) Warning(args ...any) { logger.Warn(args...) } -func (logger *Logger) Error(args ...interface{}) { +func (logger *Logger) Error(args ...any) { logger.Log(ErrorLevel, args...) } -func (logger *Logger) Fatal(args ...interface{}) { +func (logger *Logger) Fatal(args ...any) { logger.Log(FatalLevel, args...) logger.Exit(1) } -func (logger *Logger) Panic(args ...interface{}) { +func (logger *Logger) Panic(args ...any) { logger.Log(PanicLevel, args...) } -func (logger *Logger) Logln(level Level, args ...interface{}) { +func (logger *Logger) Logln(level Level, args ...any) { if logger.IsLevelEnabled(level) { entry := logger.newEntry() entry.Logln(level, args...) @@ -241,42 +241,42 @@ func (logger *Logger) Logln(level Level, args ...interface{}) { } } -func (logger *Logger) Traceln(args ...interface{}) { +func (logger *Logger) Traceln(args ...any) { logger.Logln(TraceLevel, args...) } -func (logger *Logger) Debugln(args ...interface{}) { +func (logger *Logger) Debugln(args ...any) { logger.Logln(DebugLevel, args...) } -func (logger *Logger) Infoln(args ...interface{}) { +func (logger *Logger) Infoln(args ...any) { logger.Logln(InfoLevel, args...) } -func (logger *Logger) Println(args ...interface{}) { +func (logger *Logger) Println(args ...any) { entry := logger.newEntry() entry.Println(args...) logger.releaseEntry(entry) } -func (logger *Logger) Warnln(args ...interface{}) { +func (logger *Logger) Warnln(args ...any) { logger.Logln(WarnLevel, args...) } -func (logger *Logger) Warningln(args ...interface{}) { +func (logger *Logger) Warningln(args ...any) { logger.Warnln(args...) } -func (logger *Logger) Errorln(args ...interface{}) { +func (logger *Logger) Errorln(args ...any) { logger.Logln(ErrorLevel, args...) } -func (logger *Logger) Fatalln(args ...interface{}) { +func (logger *Logger) Fatalln(args ...any) { logger.Logln(FatalLevel, args...) logger.Exit(1) } -func (logger *Logger) Panicln(args ...interface{}) { +func (logger *Logger) Panicln(args ...any) { logger.Logln(PanicLevel, args...) } @@ -288,9 +288,9 @@ func (logger *Logger) Exit(code int) { logger.ExitFunc(code) } -//When file is opened with appending mode, it's safe to -//write concurrently to a file (within 4k message on Linux). -//In these cases user can choose to disable the lock. +// When file is opened with appending mode, it's safe to +// write concurrently to a file (within 4k message on Linux). +// In these cases user can choose to disable the lock. func (logger *Logger) SetNoLock() { logger.mu.Disable() } diff --git a/vendor/github.com/sirupsen/logrus/logrus.go b/vendor/github.com/sirupsen/logrus/logrus.go index 8644761f7..19e1adc92 100644 --- a/vendor/github.com/sirupsen/logrus/logrus.go +++ b/vendor/github.com/sirupsen/logrus/logrus.go @@ -7,7 +7,7 @@ import ( ) // Fields type, used to pass to `WithFields`. -type Fields map[string]interface{} +type Fields map[string]any // Level type type Level uint32 @@ -122,51 +122,51 @@ var ( // it'll accept a stdlib logger and a logrus logger. There's no standard // interface, this is the closest we get, unfortunately. type StdLogger interface { - Print(...interface{}) - Printf(string, ...interface{}) - Println(...interface{}) + Print(...any) + Printf(string, ...any) + Println(...any) - Fatal(...interface{}) - Fatalf(string, ...interface{}) - Fatalln(...interface{}) + Fatal(...any) + Fatalf(string, ...any) + Fatalln(...any) - Panic(...interface{}) - Panicf(string, ...interface{}) - Panicln(...interface{}) + Panic(...any) + Panicf(string, ...any) + Panicln(...any) } // The FieldLogger interface generalizes the Entry and Logger types type FieldLogger interface { - WithField(key string, value interface{}) *Entry + WithField(key string, value any) *Entry WithFields(fields Fields) *Entry WithError(err error) *Entry - Debugf(format string, args ...interface{}) - Infof(format string, args ...interface{}) - Printf(format string, args ...interface{}) - Warnf(format string, args ...interface{}) - Warningf(format string, args ...interface{}) - Errorf(format string, args ...interface{}) - Fatalf(format string, args ...interface{}) - Panicf(format string, args ...interface{}) - - Debug(args ...interface{}) - Info(args ...interface{}) - Print(args ...interface{}) - Warn(args ...interface{}) - Warning(args ...interface{}) - Error(args ...interface{}) - Fatal(args ...interface{}) - Panic(args ...interface{}) - - Debugln(args ...interface{}) - Infoln(args ...interface{}) - Println(args ...interface{}) - Warnln(args ...interface{}) - Warningln(args ...interface{}) - Errorln(args ...interface{}) - Fatalln(args ...interface{}) - Panicln(args ...interface{}) + Debugf(format string, args ...any) + Infof(format string, args ...any) + Printf(format string, args ...any) + Warnf(format string, args ...any) + Warningf(format string, args ...any) + Errorf(format string, args ...any) + Fatalf(format string, args ...any) + Panicf(format string, args ...any) + + Debug(args ...any) + Info(args ...any) + Print(args ...any) + Warn(args ...any) + Warning(args ...any) + Error(args ...any) + Fatal(args ...any) + Panic(args ...any) + + Debugln(args ...any) + Infoln(args ...any) + Println(args ...any) + Warnln(args ...any) + Warningln(args ...any) + Errorln(args ...any) + Fatalln(args ...any) + Panicln(args ...any) // IsDebugEnabled() bool // IsInfoEnabled() bool @@ -180,7 +180,7 @@ type FieldLogger interface { // here for consistancy. Do not use. Use Logger or Entry instead. type Ext1FieldLogger interface { FieldLogger - Tracef(format string, args ...interface{}) - Trace(args ...interface{}) - Traceln(args ...interface{}) + Tracef(format string, args ...any) + Trace(args ...any) + Traceln(args ...any) } diff --git a/vendor/github.com/sirupsen/logrus/text_formatter.go b/vendor/github.com/sirupsen/logrus/text_formatter.go index e01587c43..8adfbd6b0 100644 --- a/vendor/github.com/sirupsen/logrus/text_formatter.go +++ b/vendor/github.com/sirupsen/logrus/text_formatter.go @@ -178,7 +178,7 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { } else { for _, key := range fixedKeys { - var value interface{} + var value any switch { case key == f.FieldMap.resolve(FieldKeyTime): value = entry.Time.Format(timestampFormat) @@ -272,7 +272,7 @@ func (f *TextFormatter) needsQuoting(text string) bool { return false } -func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) { +func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value any) { if b.Len() > 0 { b.WriteByte(' ') } @@ -281,7 +281,7 @@ func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interf f.appendValue(b, value) } -func (f *TextFormatter) appendValue(b *bytes.Buffer, value interface{}) { +func (f *TextFormatter) appendValue(b *bytes.Buffer, value any) { stringVal, ok := value.(string) if !ok { stringVal = fmt.Sprint(value) diff --git a/vendor/github.com/sirupsen/logrus/writer.go b/vendor/github.com/sirupsen/logrus/writer.go index 9e1f75135..c06d5af89 100644 --- a/vendor/github.com/sirupsen/logrus/writer.go +++ b/vendor/github.com/sirupsen/logrus/writer.go @@ -21,7 +21,7 @@ func (entry *Entry) Writer() *io.PipeWriter { func (entry *Entry) WriterLevel(level Level) *io.PipeWriter { reader, writer := io.Pipe() - var printFunc func(args ...interface{}) + var printFunc func(args ...any) switch level { case TraceLevel: @@ -48,7 +48,7 @@ func (entry *Entry) WriterLevel(level Level) *io.PipeWriter { return writer } -func (entry *Entry) writerScanner(reader *io.PipeReader, printFunc func(args ...interface{})) { +func (entry *Entry) writerScanner(reader *io.PipeReader, printFunc func(args ...any)) { scanner := bufio.NewScanner(reader) for scanner.Scan() { printFunc(scanner.Text()) diff --git a/vendor/github.com/spf13/cobra/cobra.go b/vendor/github.com/spf13/cobra/cobra.go index 7010fd15b..32df024c2 100644 --- a/vendor/github.com/spf13/cobra/cobra.go +++ b/vendor/github.com/spf13/cobra/cobra.go @@ -58,7 +58,7 @@ You need to open cmd.exe and run it from there. // AddTemplateFunc adds a template function that's available to Usage and Help // template generation. -func AddTemplateFunc(name string, tmplFunc interface{}) { +func AddTemplateFunc(name string, tmplFunc any) { templateFuncs[name] = tmplFunc } @@ -81,7 +81,7 @@ func OnInitialize(y ...func()) { // Gt takes two types and checks whether the first type is greater than the second. In case of types Arrays, Chans, // Maps and Slices, Gt will compare their lengths. Ints are compared directly while strings are first parsed as // ints and then compared. -func Gt(a interface{}, b interface{}) bool { +func Gt(a any, b any) bool { var left, right int64 av := reflect.ValueOf(a) @@ -111,7 +111,7 @@ func Gt(a interface{}, b interface{}) bool { // FIXME Eq is unused by cobra and should be removed in a version 2. It exists only for compatibility with users of cobra. // Eq takes two types and checks whether they are equal. Supported types are int and string. Unsupported types will panic. -func Eq(a interface{}, b interface{}) bool { +func Eq(a any, b any) bool { av := reflect.ValueOf(a) bv := reflect.ValueOf(b) @@ -147,7 +147,7 @@ func rpad(s string, padding int) string { } // tmpl executes the given template text on data, writing the result to w. -func tmpl(w io.Writer, text string, data interface{}) error { +func tmpl(w io.Writer, text string, data any) error { t := template.New("top") t.Funcs(templateFuncs) template.Must(t.Parse(text)) diff --git a/vendor/github.com/spf13/cobra/command.go b/vendor/github.com/spf13/cobra/command.go index 34d1bf367..11899d7c7 100644 --- a/vendor/github.com/spf13/cobra/command.go +++ b/vendor/github.com/spf13/cobra/command.go @@ -1056,17 +1056,17 @@ main: } // Print is a convenience method to Print to the defined output, fallback to Stderr if not set. -func (c *Command) Print(i ...interface{}) { +func (c *Command) Print(i ...any) { fmt.Fprint(c.OutOrStderr(), i...) } // Println is a convenience method to Println to the defined output, fallback to Stderr if not set. -func (c *Command) Println(i ...interface{}) { +func (c *Command) Println(i ...any) { c.Print(fmt.Sprintln(i...)) } // Printf is a convenience method to Printf to the defined output, fallback to Stderr if not set. -func (c *Command) Printf(format string, i ...interface{}) { +func (c *Command) Printf(format string, i ...any) { c.Print(fmt.Sprintf(format, i...)) } diff --git a/vendor/github.com/spf13/pflag/bool.go b/vendor/github.com/spf13/pflag/bool.go index c4c5c0bfd..b64daf7a1 100644 --- a/vendor/github.com/spf13/pflag/bool.go +++ b/vendor/github.com/spf13/pflag/bool.go @@ -31,7 +31,7 @@ func (b *boolValue) String() string { return strconv.FormatBool(bool(*b)) } func (b *boolValue) IsBoolFlag() bool { return true } -func boolConv(sval string) (interface{}, error) { +func boolConv(sval string) (any, error) { return strconv.ParseBool(sval) } diff --git a/vendor/github.com/spf13/pflag/bool_slice.go b/vendor/github.com/spf13/pflag/bool_slice.go index 5af02f1a7..869e05fbd 100644 --- a/vendor/github.com/spf13/pflag/bool_slice.go +++ b/vendor/github.com/spf13/pflag/bool_slice.go @@ -71,7 +71,7 @@ func (s *boolSliceValue) String() string { return "[" + out + "]" } -func boolSliceConv(val string) (interface{}, error) { +func boolSliceConv(val string) (any, error) { val = strings.Trim(val, "[]") // Empty string would cause a slice with one (empty) entry if len(val) == 0 { diff --git a/vendor/github.com/spf13/pflag/bytes.go b/vendor/github.com/spf13/pflag/bytes.go index 12c58db9f..a5b815baa 100644 --- a/vendor/github.com/spf13/pflag/bytes.go +++ b/vendor/github.com/spf13/pflag/bytes.go @@ -34,7 +34,7 @@ func newBytesHexValue(val []byte, p *[]byte) *bytesHexValue { return (*bytesHexValue)(p) } -func bytesHexConv(sval string) (interface{}, error) { +func bytesHexConv(sval string) (any, error) { bin, err := hex.DecodeString(sval) diff --git a/vendor/github.com/spf13/pflag/count.go b/vendor/github.com/spf13/pflag/count.go index aa126e44d..a2c198604 100644 --- a/vendor/github.com/spf13/pflag/count.go +++ b/vendor/github.com/spf13/pflag/count.go @@ -27,7 +27,7 @@ func (i *countValue) Type() string { func (i *countValue) String() string { return strconv.Itoa(int(*i)) } -func countConv(sval string) (interface{}, error) { +func countConv(sval string) (any, error) { i, err := strconv.Atoi(sval) if err != nil { return nil, err diff --git a/vendor/github.com/spf13/pflag/duration.go b/vendor/github.com/spf13/pflag/duration.go index e9debef88..d6ee2a616 100644 --- a/vendor/github.com/spf13/pflag/duration.go +++ b/vendor/github.com/spf13/pflag/duration.go @@ -24,7 +24,7 @@ func (d *durationValue) Type() string { func (d *durationValue) String() string { return (*time.Duration)(d).String() } -func durationConv(sval string) (interface{}, error) { +func durationConv(sval string) (any, error) { return time.ParseDuration(sval) } diff --git a/vendor/github.com/spf13/pflag/duration_slice.go b/vendor/github.com/spf13/pflag/duration_slice.go index 52c6b6dc1..a95707353 100644 --- a/vendor/github.com/spf13/pflag/duration_slice.go +++ b/vendor/github.com/spf13/pflag/duration_slice.go @@ -51,7 +51,7 @@ func (s *durationSliceValue) String() string { return "[" + strings.Join(out, ",") + "]" } -func durationSliceConv(val string) (interface{}, error) { +func durationSliceConv(val string) (any, error) { val = strings.Trim(val, "[]") // Empty string would cause a slice with one (empty) entry if len(val) == 0 { diff --git a/vendor/github.com/spf13/pflag/flag.go b/vendor/github.com/spf13/pflag/flag.go index 5eadc84e3..ac1f6ce06 100644 --- a/vendor/github.com/spf13/pflag/flag.go +++ b/vendor/github.com/spf13/pflag/flag.go @@ -27,23 +27,32 @@ unaffected. Define flags using flag.String(), Bool(), Int(), etc. This declares an integer flag, -flagname, stored in the pointer ip, with type *int. + var ip = flag.Int("flagname", 1234, "help message for flagname") + If you like, you can bind the flag to a variable using the Var() functions. + var flagvar int func init() { flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname") } + Or you can create custom flags that satisfy the Value interface (with pointer receivers) and couple them to flag parsing by + flag.Var(&flagVal, "name", "help message for flagname") + For such flags, the default value is just the initial value of the variable. After all flags are defined, call + flag.Parse() + to parse the command line into the defined flags. Flags may then be used directly. If you're using the flags themselves, they are all pointers; if you bind to variables, they're values. + fmt.Println("ip has value ", *ip) fmt.Println("flagvar has value ", flagvar) @@ -54,22 +63,26 @@ The arguments are indexed from 0 through flag.NArg()-1. The pflag package also defines some new functions that are not in flag, that give one-letter shorthands for flags. You can use these by appending 'P' to the name of any function that defines a flag. + var ip = flag.IntP("flagname", "f", 1234, "help message") var flagvar bool func init() { flag.BoolVarP("boolname", "b", true, "help message") } flag.VarP(&flagVar, "varname", "v", 1234, "help message") + Shorthand letters can be used with single dashes on the command line. Boolean shorthand flags can be combined with other shorthand flags. Command line flag syntax: + --flag // boolean flags only --flag=x Unlike the flag package, a single dash before an option means something different than a double dash. Single dashes signify a series of shorthand letters for flags. All but the last shorthand letter must be boolean flags. + // boolean flags -f -abc @@ -359,7 +372,7 @@ func (f *FlagSet) lookup(name NormalizedName) *Flag { } // func to return a given type for a given flag name -func (f *FlagSet) getFlagType(name string, ftype string, convFunc func(sval string) (interface{}, error)) (interface{}, error) { +func (f *FlagSet) getFlagType(name string, ftype string, convFunc func(sval string) (any, error)) (any, error) { flag := f.Lookup(name) if flag == nil { err := fmt.Errorf("flag accessed but not defined: %s", name) @@ -894,7 +907,7 @@ func VarP(value Value, name, shorthand, usage string) { // failf prints to standard error a formatted error and usage message and // returns the error. -func (f *FlagSet) failf(format string, a ...interface{}) error { +func (f *FlagSet) failf(format string, a ...any) error { err := fmt.Errorf(format, a...) if f.errorHandling != ContinueOnError { fmt.Fprintln(f.out(), err) @@ -915,9 +928,9 @@ func (f *FlagSet) usage() { } } -//--unknown (args will be empty) -//--unknown --next-flag ... (args will be --next-flag ...) -//--unknown arg ... (args will be arg ...) +// --unknown (args will be empty) +// --unknown --next-flag ... (args will be --next-flag ...) +// --unknown arg ... (args will be arg ...) func stripUnknownFlagValue(args []string) []string { if len(args) == 0 { //--unknown diff --git a/vendor/github.com/spf13/pflag/float32.go b/vendor/github.com/spf13/pflag/float32.go index a243f81f7..b22301ed6 100644 --- a/vendor/github.com/spf13/pflag/float32.go +++ b/vendor/github.com/spf13/pflag/float32.go @@ -22,7 +22,7 @@ func (f *float32Value) Type() string { func (f *float32Value) String() string { return strconv.FormatFloat(float64(*f), 'g', -1, 32) } -func float32Conv(sval string) (interface{}, error) { +func float32Conv(sval string) (any, error) { v, err := strconv.ParseFloat(sval, 32) if err != nil { return 0, err diff --git a/vendor/github.com/spf13/pflag/float64.go b/vendor/github.com/spf13/pflag/float64.go index 04b5492a7..4770b5d2a 100644 --- a/vendor/github.com/spf13/pflag/float64.go +++ b/vendor/github.com/spf13/pflag/float64.go @@ -22,7 +22,7 @@ func (f *float64Value) Type() string { func (f *float64Value) String() string { return strconv.FormatFloat(float64(*f), 'g', -1, 64) } -func float64Conv(sval string) (interface{}, error) { +func float64Conv(sval string) (any, error) { return strconv.ParseFloat(sval, 64) } diff --git a/vendor/github.com/spf13/pflag/int.go b/vendor/github.com/spf13/pflag/int.go index 1474b89df..5dbd818d8 100644 --- a/vendor/github.com/spf13/pflag/int.go +++ b/vendor/github.com/spf13/pflag/int.go @@ -22,7 +22,7 @@ func (i *intValue) Type() string { func (i *intValue) String() string { return strconv.Itoa(int(*i)) } -func intConv(sval string) (interface{}, error) { +func intConv(sval string) (any, error) { return strconv.Atoi(sval) } diff --git a/vendor/github.com/spf13/pflag/int16.go b/vendor/github.com/spf13/pflag/int16.go index f1a01d05e..340007161 100644 --- a/vendor/github.com/spf13/pflag/int16.go +++ b/vendor/github.com/spf13/pflag/int16.go @@ -22,7 +22,7 @@ func (i *int16Value) Type() string { func (i *int16Value) String() string { return strconv.FormatInt(int64(*i), 10) } -func int16Conv(sval string) (interface{}, error) { +func int16Conv(sval string) (any, error) { v, err := strconv.ParseInt(sval, 0, 16) if err != nil { return 0, err diff --git a/vendor/github.com/spf13/pflag/int32.go b/vendor/github.com/spf13/pflag/int32.go index 9b95944f0..d5529eb7c 100644 --- a/vendor/github.com/spf13/pflag/int32.go +++ b/vendor/github.com/spf13/pflag/int32.go @@ -22,7 +22,7 @@ func (i *int32Value) Type() string { func (i *int32Value) String() string { return strconv.FormatInt(int64(*i), 10) } -func int32Conv(sval string) (interface{}, error) { +func int32Conv(sval string) (any, error) { v, err := strconv.ParseInt(sval, 0, 32) if err != nil { return 0, err diff --git a/vendor/github.com/spf13/pflag/int64.go b/vendor/github.com/spf13/pflag/int64.go index 0026d781d..303d79756 100644 --- a/vendor/github.com/spf13/pflag/int64.go +++ b/vendor/github.com/spf13/pflag/int64.go @@ -22,7 +22,7 @@ func (i *int64Value) Type() string { func (i *int64Value) String() string { return strconv.FormatInt(int64(*i), 10) } -func int64Conv(sval string) (interface{}, error) { +func int64Conv(sval string) (any, error) { return strconv.ParseInt(sval, 0, 64) } diff --git a/vendor/github.com/spf13/pflag/int8.go b/vendor/github.com/spf13/pflag/int8.go index 4da92228e..e853021f9 100644 --- a/vendor/github.com/spf13/pflag/int8.go +++ b/vendor/github.com/spf13/pflag/int8.go @@ -22,7 +22,7 @@ func (i *int8Value) Type() string { func (i *int8Value) String() string { return strconv.FormatInt(int64(*i), 10) } -func int8Conv(sval string) (interface{}, error) { +func int8Conv(sval string) (any, error) { v, err := strconv.ParseInt(sval, 0, 8) if err != nil { return 0, err diff --git a/vendor/github.com/spf13/pflag/int_slice.go b/vendor/github.com/spf13/pflag/int_slice.go index 1e7c9edde..fc7faa39e 100644 --- a/vendor/github.com/spf13/pflag/int_slice.go +++ b/vendor/github.com/spf13/pflag/int_slice.go @@ -51,7 +51,7 @@ func (s *intSliceValue) String() string { return "[" + strings.Join(out, ",") + "]" } -func intSliceConv(val string) (interface{}, error) { +func intSliceConv(val string) (any, error) { val = strings.Trim(val, "[]") // Empty string would cause a slice with one (empty) entry if len(val) == 0 { diff --git a/vendor/github.com/spf13/pflag/ip.go b/vendor/github.com/spf13/pflag/ip.go index 3d414ba69..8e60ba811 100644 --- a/vendor/github.com/spf13/pflag/ip.go +++ b/vendor/github.com/spf13/pflag/ip.go @@ -28,7 +28,7 @@ func (i *ipValue) Type() string { return "ip" } -func ipConv(sval string) (interface{}, error) { +func ipConv(sval string) (any, error) { ip := net.ParseIP(sval) if ip != nil { return ip, nil diff --git a/vendor/github.com/spf13/pflag/ip_slice.go b/vendor/github.com/spf13/pflag/ip_slice.go index 7dd196fe3..9efe89b42 100644 --- a/vendor/github.com/spf13/pflag/ip_slice.go +++ b/vendor/github.com/spf13/pflag/ip_slice.go @@ -72,7 +72,7 @@ func (s *ipSliceValue) String() string { return "[" + out + "]" } -func ipSliceConv(val string) (interface{}, error) { +func ipSliceConv(val string) (any, error) { val = strings.Trim(val, "[]") // Emtpy string would cause a slice with one (empty) entry if len(val) == 0 { diff --git a/vendor/github.com/spf13/pflag/ipmask.go b/vendor/github.com/spf13/pflag/ipmask.go index 5bd44bd21..3d09bb638 100644 --- a/vendor/github.com/spf13/pflag/ipmask.go +++ b/vendor/github.com/spf13/pflag/ipmask.go @@ -56,7 +56,7 @@ func ParseIPv4Mask(s string) net.IPMask { return net.IPv4Mask(mask[12], mask[13], mask[14], mask[15]) } -func parseIPv4Mask(sval string) (interface{}, error) { +func parseIPv4Mask(sval string) (any, error) { mask := ParseIPv4Mask(sval) if mask == nil { return nil, fmt.Errorf("unable to parse %s as net.IPMask", sval) diff --git a/vendor/github.com/spf13/pflag/ipnet.go b/vendor/github.com/spf13/pflag/ipnet.go index e2c1b8bcd..fd0785fb6 100644 --- a/vendor/github.com/spf13/pflag/ipnet.go +++ b/vendor/github.com/spf13/pflag/ipnet.go @@ -32,7 +32,7 @@ func newIPNetValue(val net.IPNet, p *net.IPNet) *ipNetValue { return (*ipNetValue)(p) } -func ipNetConv(sval string) (interface{}, error) { +func ipNetConv(sval string) (any, error) { _, n, err := net.ParseCIDR(strings.TrimSpace(sval)) if err == nil { return *n, nil diff --git a/vendor/github.com/spf13/pflag/string.go b/vendor/github.com/spf13/pflag/string.go index 04e0a26ff..6cbfc3c46 100644 --- a/vendor/github.com/spf13/pflag/string.go +++ b/vendor/github.com/spf13/pflag/string.go @@ -18,7 +18,7 @@ func (s *stringValue) Type() string { func (s *stringValue) String() string { return string(*s) } -func stringConv(sval string) (interface{}, error) { +func stringConv(sval string) (any, error) { return sval, nil } diff --git a/vendor/github.com/spf13/pflag/string_array.go b/vendor/github.com/spf13/pflag/string_array.go index fa7bc6018..e8dc0beaa 100644 --- a/vendor/github.com/spf13/pflag/string_array.go +++ b/vendor/github.com/spf13/pflag/string_array.go @@ -32,7 +32,7 @@ func (s *stringArrayValue) String() string { return "[" + str + "]" } -func stringArrayConv(sval string) (interface{}, error) { +func stringArrayConv(sval string) (any, error) { sval = sval[1 : len(sval)-1] // An empty string would cause a array with one (empty) string if len(sval) == 0 { diff --git a/vendor/github.com/spf13/pflag/string_slice.go b/vendor/github.com/spf13/pflag/string_slice.go index 0cd3ccc08..a085ec246 100644 --- a/vendor/github.com/spf13/pflag/string_slice.go +++ b/vendor/github.com/spf13/pflag/string_slice.go @@ -62,7 +62,7 @@ func (s *stringSliceValue) String() string { return "[" + str + "]" } -func stringSliceConv(sval string) (interface{}, error) { +func stringSliceConv(sval string) (any, error) { sval = sval[1 : len(sval)-1] // An empty string would cause a slice with one (empty) string if len(sval) == 0 { @@ -84,9 +84,12 @@ func (f *FlagSet) GetStringSlice(name string) ([]string, error) { // The argument p points to a []string variable in which to store the value of the flag. // Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly. // For example: -// --ss="v1,v2" -ss="v3" +// +// --ss="v1,v2" -ss="v3" +// // will result in -// []string{"v1", "v2", "v3"} +// +// []string{"v1", "v2", "v3"} func (f *FlagSet) StringSliceVar(p *[]string, name string, value []string, usage string) { f.VarP(newStringSliceValue(value, p), name, "", usage) } @@ -100,9 +103,12 @@ func (f *FlagSet) StringSliceVarP(p *[]string, name, shorthand string, value []s // The argument p points to a []string variable in which to store the value of the flag. // Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly. // For example: -// --ss="v1,v2" -ss="v3" +// +// --ss="v1,v2" -ss="v3" +// // will result in -// []string{"v1", "v2", "v3"} +// +// []string{"v1", "v2", "v3"} func StringSliceVar(p *[]string, name string, value []string, usage string) { CommandLine.VarP(newStringSliceValue(value, p), name, "", usage) } @@ -116,9 +122,12 @@ func StringSliceVarP(p *[]string, name, shorthand string, value []string, usage // The return value is the address of a []string variable that stores the value of the flag. // Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly. // For example: -// --ss="v1,v2" -ss="v3" +// +// --ss="v1,v2" -ss="v3" +// // will result in -// []string{"v1", "v2", "v3"} +// +// []string{"v1", "v2", "v3"} func (f *FlagSet) StringSlice(name string, value []string, usage string) *[]string { p := []string{} f.StringSliceVarP(&p, name, "", value, usage) @@ -136,9 +145,12 @@ func (f *FlagSet) StringSliceP(name, shorthand string, value []string, usage str // The return value is the address of a []string variable that stores the value of the flag. // Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly. // For example: -// --ss="v1,v2" -ss="v3" +// +// --ss="v1,v2" -ss="v3" +// // will result in -// []string{"v1", "v2", "v3"} +// +// []string{"v1", "v2", "v3"} func StringSlice(name string, value []string, usage string) *[]string { return CommandLine.StringSliceP(name, "", value, usage) } diff --git a/vendor/github.com/spf13/pflag/uint.go b/vendor/github.com/spf13/pflag/uint.go index dcbc2b758..100cef9a5 100644 --- a/vendor/github.com/spf13/pflag/uint.go +++ b/vendor/github.com/spf13/pflag/uint.go @@ -22,7 +22,7 @@ func (i *uintValue) Type() string { func (i *uintValue) String() string { return strconv.FormatUint(uint64(*i), 10) } -func uintConv(sval string) (interface{}, error) { +func uintConv(sval string) (any, error) { v, err := strconv.ParseUint(sval, 0, 0) if err != nil { return 0, err diff --git a/vendor/github.com/spf13/pflag/uint16.go b/vendor/github.com/spf13/pflag/uint16.go index 7e9914edd..c3706ec13 100644 --- a/vendor/github.com/spf13/pflag/uint16.go +++ b/vendor/github.com/spf13/pflag/uint16.go @@ -22,7 +22,7 @@ func (i *uint16Value) Type() string { func (i *uint16Value) String() string { return strconv.FormatUint(uint64(*i), 10) } -func uint16Conv(sval string) (interface{}, error) { +func uint16Conv(sval string) (any, error) { v, err := strconv.ParseUint(sval, 0, 16) if err != nil { return 0, err diff --git a/vendor/github.com/spf13/pflag/uint32.go b/vendor/github.com/spf13/pflag/uint32.go index d8024539b..d00c9c3de 100644 --- a/vendor/github.com/spf13/pflag/uint32.go +++ b/vendor/github.com/spf13/pflag/uint32.go @@ -22,7 +22,7 @@ func (i *uint32Value) Type() string { func (i *uint32Value) String() string { return strconv.FormatUint(uint64(*i), 10) } -func uint32Conv(sval string) (interface{}, error) { +func uint32Conv(sval string) (any, error) { v, err := strconv.ParseUint(sval, 0, 32) if err != nil { return 0, err diff --git a/vendor/github.com/spf13/pflag/uint64.go b/vendor/github.com/spf13/pflag/uint64.go index f62240f2c..e9d7c6665 100644 --- a/vendor/github.com/spf13/pflag/uint64.go +++ b/vendor/github.com/spf13/pflag/uint64.go @@ -22,7 +22,7 @@ func (i *uint64Value) Type() string { func (i *uint64Value) String() string { return strconv.FormatUint(uint64(*i), 10) } -func uint64Conv(sval string) (interface{}, error) { +func uint64Conv(sval string) (any, error) { v, err := strconv.ParseUint(sval, 0, 64) if err != nil { return 0, err diff --git a/vendor/github.com/spf13/pflag/uint8.go b/vendor/github.com/spf13/pflag/uint8.go index bb0e83c1f..6fc99d939 100644 --- a/vendor/github.com/spf13/pflag/uint8.go +++ b/vendor/github.com/spf13/pflag/uint8.go @@ -22,7 +22,7 @@ func (i *uint8Value) Type() string { func (i *uint8Value) String() string { return strconv.FormatUint(uint64(*i), 10) } -func uint8Conv(sval string) (interface{}, error) { +func uint8Conv(sval string) (any, error) { v, err := strconv.ParseUint(sval, 0, 8) if err != nil { return 0, err diff --git a/vendor/github.com/spf13/pflag/uint_slice.go b/vendor/github.com/spf13/pflag/uint_slice.go index edd94c600..ec307410b 100644 --- a/vendor/github.com/spf13/pflag/uint_slice.go +++ b/vendor/github.com/spf13/pflag/uint_slice.go @@ -50,7 +50,7 @@ func (s *uintSliceValue) String() string { return "[" + strings.Join(out, ",") + "]" } -func uintSliceConv(val string) (interface{}, error) { +func uintSliceConv(val string) (any, error) { val = strings.Trim(val, "[]") // Empty string would cause a slice with one (empty) entry if len(val) == 0 { diff --git a/vendor/github.com/tmc/grpc-websocket-proxy/wsproxy/websocket_proxy.go b/vendor/github.com/tmc/grpc-websocket-proxy/wsproxy/websocket_proxy.go index 0fca05a00..c00ab6961 100644 --- a/vendor/github.com/tmc/grpc-websocket-proxy/wsproxy/websocket_proxy.go +++ b/vendor/github.com/tmc/grpc-websocket-proxy/wsproxy/websocket_proxy.go @@ -35,8 +35,8 @@ type Proxy struct { // Logger collects log messages. type Logger interface { - Warnln(...interface{}) - Debugln(...interface{}) + Warnln(...any) + Debugln(...any) } func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { @@ -85,9 +85,12 @@ func WithLogger(logger Logger) Option { // The cookie name is specified by the TokenCookieName value. // // example: -// Sec-Websocket-Protocol: Bearer, foobar +// +// Sec-Websocket-Protocol: Bearer, foobar +// // is converted to: -// Authorization: Bearer foobar +// +// Authorization: Bearer foobar // // Method can be overwritten with the MethodOverrideParam get parameter in the requested URL func WebsocketProxy(h http.Handler, opts ...Option) http.Handler { diff --git a/vendor/github.com/urfave/cli/app.go b/vendor/github.com/urfave/cli/app.go index 51fc45d87..64db2f2a8 100644 --- a/vendor/github.com/urfave/cli/app.go +++ b/vendor/github.com/urfave/cli/app.go @@ -63,7 +63,7 @@ type App struct { // The action to execute when no subcommands are specified // Expects a `cli.ActionFunc` but will accept the *deprecated* signature of `func(*cli.Context) {}` // *Note*: support for the deprecated `Action` signature will be removed in a future version - Action interface{} + Action any // Execute this function if the proper command cannot be found CommandNotFound CommandNotFoundFunc @@ -84,7 +84,7 @@ type App struct { // ErrWriter writes error output ErrWriter io.Writer // Other custom info - Metadata map[string]interface{} + Metadata map[string]any // Carries a function which returns app specific info. ExtraInfo func() map[string]string // CustomAppHelpTemplate the text template for app help topic. @@ -162,7 +162,7 @@ func (a *App) Setup() { sort.Sort(a.categories) if a.Metadata == nil { - a.Metadata = make(map[string]interface{}) + a.Metadata = make(map[string]any) } if a.Writer == nil { @@ -483,7 +483,7 @@ func (a Author) String() string { // HandleAction attempts to figure out which Action signature was used. If // it's an ActionFunc or a func with the legacy signature for Action, the func // is run! -func HandleAction(action interface{}, context *Context) (err error) { +func HandleAction(action any, context *Context) (err error) { if a, ok := action.(ActionFunc); ok { return a(context) } else if a, ok := action.(func(*Context) error); ok { diff --git a/vendor/github.com/urfave/cli/command.go b/vendor/github.com/urfave/cli/command.go index 23de2944b..a2935926c 100644 --- a/vendor/github.com/urfave/cli/command.go +++ b/vendor/github.com/urfave/cli/command.go @@ -34,7 +34,7 @@ type Command struct { // It is run even if Action() panics After AfterFunc // The function to call when this command is invoked - Action interface{} + Action any // TODO: replace `Action: interface{}` with `Action: ActionFunc` once some kind // of deprecation period has passed, maybe? diff --git a/vendor/github.com/urfave/cli/context.go b/vendor/github.com/urfave/cli/context.go index db94191e2..1ccc06a17 100644 --- a/vendor/github.com/urfave/cli/context.go +++ b/vendor/github.com/urfave/cli/context.go @@ -157,7 +157,7 @@ func (c *Context) Parent() *Context { } // value returns the value of the flag coressponding to `name` -func (c *Context) value(name string) interface{} { +func (c *Context) value(name string) any { return c.flagSet.Lookup(name).Value.(flag.Getter).Get() } diff --git a/vendor/github.com/urfave/cli/errors.go b/vendor/github.com/urfave/cli/errors.go index 562b2953c..aa8b1f960 100644 --- a/vendor/github.com/urfave/cli/errors.go +++ b/vendor/github.com/urfave/cli/errors.go @@ -48,11 +48,11 @@ type ExitCoder interface { // ExitError fulfills both the builtin `error` interface and `ExitCoder` type ExitError struct { exitCode int - message interface{} + message any } // NewExitError makes a new *ExitError -func NewExitError(message interface{}, exitCode int) *ExitError { +func NewExitError(message any, exitCode int) *ExitError { return &ExitError{ exitCode: exitCode, message: message, diff --git a/vendor/github.com/urfave/cli/flag.go b/vendor/github.com/urfave/cli/flag.go index 877ff3523..5027aebbf 100644 --- a/vendor/github.com/urfave/cli/flag.go +++ b/vendor/github.com/urfave/cli/flag.go @@ -151,7 +151,7 @@ func (f *StringSlice) Value() []string { } // Get returns the slice of strings set by this flag -func (f *StringSlice) Get() interface{} { +func (f *StringSlice) Get() any { return *f } @@ -214,7 +214,7 @@ func (f *IntSlice) Value() []int { } // Get returns the slice of ints set by this flag -func (f *IntSlice) Get() interface{} { +func (f *IntSlice) Get() any { return *f } @@ -277,7 +277,7 @@ func (f *Int64Slice) Value() []int64 { } // Get returns the slice of ints set by this flag -func (f *Int64Slice) Get() interface{} { +func (f *Int64Slice) Get() any { return *f } diff --git a/vendor/github.com/urfave/cli/flag_generated.go b/vendor/github.com/urfave/cli/flag_generated.go index 491b61956..752568c6f 100644 --- a/vendor/github.com/urfave/cli/flag_generated.go +++ b/vendor/github.com/urfave/cli/flag_generated.go @@ -220,20 +220,20 @@ func (f GenericFlag) GetName() string { // Generic looks up the value of a local GenericFlag, returns // nil if not found -func (c *Context) Generic(name string) interface{} { +func (c *Context) Generic(name string) any { return lookupGeneric(name, c.flagSet) } // GlobalGeneric looks up the value of a global GenericFlag, returns // nil if not found -func (c *Context) GlobalGeneric(name string) interface{} { +func (c *Context) GlobalGeneric(name string) any { if fs := lookupGlobalFlagSet(name, c); fs != nil { return lookupGeneric(name, fs) } return nil } -func lookupGeneric(name string, set *flag.FlagSet) interface{} { +func lookupGeneric(name string, set *flag.FlagSet) any { f := set.Lookup(name) if f != nil { parsed, err := f.Value, error(nil) diff --git a/vendor/github.com/urfave/cli/help.go b/vendor/github.com/urfave/cli/help.go index 57ec98d58..be900d243 100644 --- a/vendor/github.com/urfave/cli/help.go +++ b/vendor/github.com/urfave/cli/help.go @@ -110,10 +110,10 @@ var helpSubcommand = Command{ } // Prints help for the App or Command -type helpPrinter func(w io.Writer, templ string, data interface{}) +type helpPrinter func(w io.Writer, templ string, data any) // Prints help for the App or Command with custom template function. -type helpPrinterCustom func(w io.Writer, templ string, data interface{}, customFunc map[string]interface{}) +type helpPrinterCustom func(w io.Writer, templ string, data any, customFunc map[string]any) // HelpPrinter is a function that writes the help output. If not set a default // is used. The function signature is: @@ -139,11 +139,11 @@ func ShowAppHelp(c *Context) (err error) { HelpPrinter(c.App.Writer, AppHelpTemplate, c.App) return } - customAppData := func() map[string]interface{} { + customAppData := func() map[string]any { if c.App.ExtraInfo == nil { return nil } - return map[string]interface{}{ + return map[string]any{ "ExtraInfo": c.App.ExtraInfo, } } @@ -226,7 +226,7 @@ func ShowCommandCompletions(ctx *Context, command string) { } } -func printHelpCustom(out io.Writer, templ string, data interface{}, customFunc map[string]interface{}) { +func printHelpCustom(out io.Writer, templ string, data any, customFunc map[string]any) { funcMap := template.FuncMap{ "join": strings.Join, } @@ -250,7 +250,7 @@ func printHelpCustom(out io.Writer, templ string, data interface{}, customFunc m w.Flush() } -func printHelp(out io.Writer, templ string, data interface{}) { +func printHelp(out io.Writer, templ string, data any) { printHelpCustom(out, templ, data, nil) } diff --git a/vendor/go.etcd.io/bbolt/db.go b/vendor/go.etcd.io/bbolt/db.go index 80b0095cc..3d83f8df2 100644 --- a/vendor/go.etcd.io/bbolt/db.go +++ b/vendor/go.etcd.io/bbolt/db.go @@ -268,7 +268,7 @@ func Open(path string, mode os.FileMode, options *Options) (*DB, error) { // Initialize page pool. db.pagePool = sync.Pool{ - New: func() interface{} { + New: func() any { return make([]byte, db.pageSize) }, } @@ -841,7 +841,7 @@ retry: var trySolo = errors.New("batch function returned an error and should be re-run solo") type panicked struct { - reason interface{} + reason any } func (p panicked) Error() string { @@ -1167,7 +1167,7 @@ func (m *meta) sum64() uint64 { } // _assert will panic with a given formatted message if the given condition is false. -func _assert(condition bool, msg string, v ...interface{}) { +func _assert(condition bool, msg string, v ...any) { if !condition { panic(fmt.Sprintf("assertion failed: "+msg, v...)) } diff --git a/vendor/go.uber.org/multierr/error.go b/vendor/go.uber.org/multierr/error.go index 04eb9618c..9b36ad9f6 100644 --- a/vendor/go.uber.org/multierr/error.go +++ b/vendor/go.uber.org/multierr/error.go @@ -20,54 +20,54 @@ // Package multierr allows combining one or more errors together. // -// Overview +// # Overview // // Errors can be combined with the use of the Combine function. // -// multierr.Combine( -// reader.Close(), -// writer.Close(), -// conn.Close(), -// ) +// multierr.Combine( +// reader.Close(), +// writer.Close(), +// conn.Close(), +// ) // // If only two errors are being combined, the Append function may be used // instead. // -// err = multierr.Append(reader.Close(), writer.Close()) +// err = multierr.Append(reader.Close(), writer.Close()) // // This makes it possible to record resource cleanup failures from deferred // blocks with the help of named return values. // -// func sendRequest(req Request) (err error) { -// conn, err := openConnection() -// if err != nil { -// return err -// } -// defer func() { -// err = multierr.Append(err, conn.Close()) -// }() -// // ... -// } +// func sendRequest(req Request) (err error) { +// conn, err := openConnection() +// if err != nil { +// return err +// } +// defer func() { +// err = multierr.Append(err, conn.Close()) +// }() +// // ... +// } // // The underlying list of errors for a returned error object may be retrieved // with the Errors function. // -// errors := multierr.Errors(err) -// if len(errors) > 0 { -// fmt.Println("The following errors occurred:") -// } +// errors := multierr.Errors(err) +// if len(errors) > 0 { +// fmt.Println("The following errors occurred:") +// } // -// Advanced Usage +// # Advanced Usage // // Errors returned by Combine and Append MAY implement the following // interface. // -// type errorGroup interface { -// // Returns a slice containing the underlying list of errors. -// // -// // This slice MUST NOT be modified by the caller. -// Errors() []error -// } +// type errorGroup interface { +// // Returns a slice containing the underlying list of errors. +// // +// // This slice MUST NOT be modified by the caller. +// Errors() []error +// } // // Note that if you need access to list of errors behind a multierr error, you // should prefer using the Errors function. That said, if you need cheap @@ -76,13 +76,13 @@ // because errors returned by Combine and Append are not guaranteed to // implement this interface. // -// var errors []error -// group, ok := err.(errorGroup) -// if ok { -// errors = group.Errors() -// } else { -// errors = []error{err} -// } +// var errors []error +// group, ok := err.(errorGroup) +// if ok { +// errors = group.Errors() +// } else { +// errors = []error{err} +// } package multierr // import "go.uber.org/multierr" import ( @@ -120,7 +120,7 @@ var ( // _bufferPool is a pool of bytes.Buffers. var _bufferPool = sync.Pool{ - New: func() interface{} { + New: func() any { return &bytes.Buffer{} }, } @@ -132,8 +132,8 @@ type errorGroup interface { // Errors returns a slice containing zero or more errors that the supplied // error is composed of. If the error is nil, a nil slice is returned. // -// err := multierr.Append(r.Close(), w.Close()) -// errors := multierr.Errors(err) +// err := multierr.Append(r.Close(), w.Close()) +// errors := multierr.Errors(err) // // If the error is not composed of other errors, the returned slice contains // just the error that was passed in. @@ -327,32 +327,32 @@ func fromSlice(errors []error) error { // If zero arguments were passed or if all items are nil, a nil error is // returned. // -// Combine(nil, nil) // == nil +// Combine(nil, nil) // == nil // // If only a single error was passed, it is returned as-is. // -// Combine(err) // == err +// Combine(err) // == err // // Combine skips over nil arguments so this function may be used to combine // together errors from operations that fail independently of each other. // -// multierr.Combine( -// reader.Close(), -// writer.Close(), -// pipe.Close(), -// ) +// multierr.Combine( +// reader.Close(), +// writer.Close(), +// pipe.Close(), +// ) // // If any of the passed errors is a multierr error, it will be flattened along // with the other errors. // -// multierr.Combine(multierr.Combine(err1, err2), err3) -// // is the same as -// multierr.Combine(err1, err2, err3) +// multierr.Combine(multierr.Combine(err1, err2), err3) +// // is the same as +// multierr.Combine(err1, err2, err3) // // The returned error formats into a readable multi-line error message if // formatted with %+v. // -// fmt.Sprintf("%+v", multierr.Combine(err1, err2)) +// fmt.Sprintf("%+v", multierr.Combine(err1, err2)) func Combine(errors ...error) error { return fromSlice(errors) } @@ -362,16 +362,16 @@ func Combine(errors ...error) error { // This function is a specialization of Combine for the common case where // there are only two errors. // -// err = multierr.Append(reader.Close(), writer.Close()) +// err = multierr.Append(reader.Close(), writer.Close()) // // The following pattern may also be used to record failure of deferred // operations without losing information about the original error. // -// func doSomething(..) (err error) { -// f := acquireResource() -// defer func() { -// err = multierr.Append(err, f.Close()) -// }() +// func doSomething(..) (err error) { +// f := acquireResource() +// defer func() { +// err = multierr.Append(err, f.Close()) +// }() func Append(left error, right error) error { switch { case left == nil: @@ -401,37 +401,37 @@ func Append(left error, right error) error { // AppendInto appends an error into the destination of an error pointer and // returns whether the error being appended was non-nil. // -// var err error -// multierr.AppendInto(&err, r.Close()) -// multierr.AppendInto(&err, w.Close()) +// var err error +// multierr.AppendInto(&err, r.Close()) +// multierr.AppendInto(&err, w.Close()) // // The above is equivalent to, // -// err := multierr.Append(r.Close(), w.Close()) +// err := multierr.Append(r.Close(), w.Close()) // // As AppendInto reports whether the provided error was non-nil, it may be // used to build a multierr error in a loop more ergonomically. For example: // -// var err error -// for line := range lines { -// var item Item -// if multierr.AppendInto(&err, parse(line, &item)) { -// continue -// } -// items = append(items, item) -// } +// var err error +// for line := range lines { +// var item Item +// if multierr.AppendInto(&err, parse(line, &item)) { +// continue +// } +// items = append(items, item) +// } // // Compare this with a verison that relies solely on Append: // -// var err error -// for line := range lines { -// var item Item -// if parseErr := parse(line, &item); parseErr != nil { -// err = multierr.Append(err, parseErr) -// continue -// } -// items = append(items, item) -// } +// var err error +// for line := range lines { +// var item Item +// if parseErr := parse(line, &item); parseErr != nil { +// err = multierr.Append(err, parseErr) +// continue +// } +// items = append(items, item) +// } func AppendInto(into *error, err error) (errored bool) { if into == nil { // We panic if 'into' is nil. This is not documented above diff --git a/vendor/go.uber.org/multierr/go113.go b/vendor/go.uber.org/multierr/go113.go index 264b0eac0..b39d8f230 100644 --- a/vendor/go.uber.org/multierr/go113.go +++ b/vendor/go.uber.org/multierr/go113.go @@ -18,6 +18,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +//go:build go1.13 // +build go1.13 package multierr @@ -29,7 +30,7 @@ import "errors" // // This function allows errors.As to traverse the values stored on the // multierr error. -func (merr *multiError) As(target interface{}) bool { +func (merr *multiError) As(target any) bool { for _, err := range merr.Errors() { if errors.As(err, target) { return true diff --git a/vendor/go.uber.org/zap/buffer/pool.go b/vendor/go.uber.org/zap/buffer/pool.go index 8fb3e202c..9b17198df 100644 --- a/vendor/go.uber.org/zap/buffer/pool.go +++ b/vendor/go.uber.org/zap/buffer/pool.go @@ -30,7 +30,7 @@ type Pool struct { // NewPool constructs a new Pool. func NewPool() Pool { return Pool{p: &sync.Pool{ - New: func() interface{} { + New: func() any { return &Buffer{bs: make([]byte, 0, _size)} }, }} diff --git a/vendor/go.uber.org/zap/config.go b/vendor/go.uber.org/zap/config.go index eae1d237f..d7a8e0f1d 100644 --- a/vendor/go.uber.org/zap/config.go +++ b/vendor/go.uber.org/zap/config.go @@ -86,7 +86,7 @@ type Config struct { // logs, see the package-level AdvancedConfiguration example. ErrorOutputPaths []string `json:"errorOutputPaths" yaml:"errorOutputPaths"` // InitialFields is a collection of fields to add to the root logger. - InitialFields map[string]interface{} `json:"initialFields" yaml:"initialFields"` + InitialFields map[string]any `json:"initialFields" yaml:"initialFields"` } // NewProductionEncoderConfig returns an opinionated EncoderConfig for diff --git a/vendor/go.uber.org/zap/doc.go b/vendor/go.uber.org/zap/doc.go index 8638dd1b9..3c50d7b4d 100644 --- a/vendor/go.uber.org/zap/doc.go +++ b/vendor/go.uber.org/zap/doc.go @@ -32,7 +32,7 @@ // they need to count every allocation and when they'd prefer a more familiar, // loosely typed API. // -// Choosing a Logger +// # Choosing a Logger // // In contexts where performance is nice, but not critical, use the // SugaredLogger. It's 4-10x faster than other structured logging packages and @@ -41,14 +41,15 @@ // variadic number of key-value pairs. (For more advanced use cases, they also // accept strongly typed fields - see the SugaredLogger.With documentation for // details.) -// sugar := zap.NewExample().Sugar() -// defer sugar.Sync() -// sugar.Infow("failed to fetch URL", -// "url", "http://example.com", -// "attempt", 3, -// "backoff", time.Second, -// ) -// sugar.Infof("failed to fetch URL: %s", "http://example.com") +// +// sugar := zap.NewExample().Sugar() +// defer sugar.Sync() +// sugar.Infow("failed to fetch URL", +// "url", "http://example.com", +// "attempt", 3, +// "backoff", time.Second, +// ) +// sugar.Infof("failed to fetch URL: %s", "http://example.com") // // By default, loggers are unbuffered. However, since zap's low-level APIs // allow buffering, calling Sync before letting your process exit is a good @@ -57,32 +58,35 @@ // In the rare contexts where every microsecond and every allocation matter, // use the Logger. It's even faster than the SugaredLogger and allocates far // less, but it only supports strongly-typed, structured logging. -// logger := zap.NewExample() -// defer logger.Sync() -// logger.Info("failed to fetch URL", -// zap.String("url", "http://example.com"), -// zap.Int("attempt", 3), -// zap.Duration("backoff", time.Second), -// ) +// +// logger := zap.NewExample() +// defer logger.Sync() +// logger.Info("failed to fetch URL", +// zap.String("url", "http://example.com"), +// zap.Int("attempt", 3), +// zap.Duration("backoff", time.Second), +// ) // // Choosing between the Logger and SugaredLogger doesn't need to be an // application-wide decision: converting between the two is simple and // inexpensive. -// logger := zap.NewExample() -// defer logger.Sync() -// sugar := logger.Sugar() -// plain := sugar.Desugar() // -// Configuring Zap +// logger := zap.NewExample() +// defer logger.Sync() +// sugar := logger.Sugar() +// plain := sugar.Desugar() +// +// # Configuring Zap // // The simplest way to build a Logger is to use zap's opinionated presets: // NewExample, NewProduction, and NewDevelopment. These presets build a logger // with a single function call: -// logger, err := zap.NewProduction() -// if err != nil { -// log.Fatalf("can't initialize zap logger: %v", err) -// } -// defer logger.Sync() +// +// logger, err := zap.NewProduction() +// if err != nil { +// log.Fatalf("can't initialize zap logger: %v", err) +// } +// defer logger.Sync() // // Presets are fine for small projects, but larger projects and organizations // naturally require a bit more customization. For most users, zap's Config @@ -94,7 +98,7 @@ // go.uber.org/zap/zapcore. See the package-level AdvancedConfiguration // example for sample code. // -// Extending Zap +// # Extending Zap // // The zap package itself is a relatively thin wrapper around the interfaces // in go.uber.org/zap/zapcore. Extending zap to support a new encoding (e.g., @@ -106,7 +110,7 @@ // Similarly, package authors can use the high-performance Encoder and Core // implementations in the zapcore package to build their own loggers. // -// Frequently Asked Questions +// # Frequently Asked Questions // // An FAQ covering everything from installation errors to design decisions is // available at https://github.com/uber-go/zap/blob/master/FAQ.md. diff --git a/vendor/go.uber.org/zap/error.go b/vendor/go.uber.org/zap/error.go index 65982a51e..f080c540a 100644 --- a/vendor/go.uber.org/zap/error.go +++ b/vendor/go.uber.org/zap/error.go @@ -26,7 +26,7 @@ import ( "go.uber.org/zap/zapcore" ) -var _errArrayElemPool = sync.Pool{New: func() interface{} { +var _errArrayElemPool = sync.Pool{New: func() any { return &errArrayElem{} }} diff --git a/vendor/go.uber.org/zap/field.go b/vendor/go.uber.org/zap/field.go index 83c1ea245..a85604f7f 100644 --- a/vendor/go.uber.org/zap/field.go +++ b/vendor/go.uber.org/zap/field.go @@ -317,7 +317,7 @@ func Uintptrp(key string, val *uintptr) Field { // // If encoding fails (e.g., trying to serialize a map[int]string to JSON), Reflect // includes the error message in the final log output. -func Reflect(key string, val interface{}) Field { +func Reflect(key string, val any) Field { return Field{Key: key, Type: zapcore.ReflectType, Interface: val} } @@ -393,7 +393,7 @@ func Object(key string, val zapcore.ObjectMarshaler) Field { // Since byte/uint8 and rune/int32 are aliases, Any can't differentiate between // them. To minimize surprises, []byte values are treated as binary blobs, byte // values are treated as uint8, and runes are always treated as integers. -func Any(key string, value interface{}) Field { +func Any(key string, value any) Field { switch val := value.(type) { case zapcore.ObjectMarshaler: return Object(key, val) diff --git a/vendor/go.uber.org/zap/stacktrace.go b/vendor/go.uber.org/zap/stacktrace.go index 100fac216..a2063c77e 100644 --- a/vendor/go.uber.org/zap/stacktrace.go +++ b/vendor/go.uber.org/zap/stacktrace.go @@ -32,7 +32,7 @@ const _zapPackage = "go.uber.org/zap" var ( _stacktracePool = sync.Pool{ - New: func() interface{} { + New: func() any { return newProgramCounters(64) }, } diff --git a/vendor/go.uber.org/zap/sugar.go b/vendor/go.uber.org/zap/sugar.go index 77ca227f4..f0d70174a 100644 --- a/vendor/go.uber.org/zap/sugar.go +++ b/vendor/go.uber.org/zap/sugar.go @@ -67,100 +67,103 @@ func (s *SugaredLogger) Named(name string) *SugaredLogger { // and the second as the field value. // // For example, -// sugaredLogger.With( -// "hello", "world", -// "failure", errors.New("oh no"), -// Stack(), -// "count", 42, -// "user", User{Name: "alice"}, -// ) +// +// sugaredLogger.With( +// "hello", "world", +// "failure", errors.New("oh no"), +// Stack(), +// "count", 42, +// "user", User{Name: "alice"}, +// ) +// // is the equivalent of -// unsugared.With( -// String("hello", "world"), -// String("failure", "oh no"), -// Stack(), -// Int("count", 42), -// Object("user", User{Name: "alice"}), -// ) +// +// unsugared.With( +// String("hello", "world"), +// String("failure", "oh no"), +// Stack(), +// Int("count", 42), +// Object("user", User{Name: "alice"}), +// ) // // Note that the keys in key-value pairs should be strings. In development, // passing a non-string key panics. In production, the logger is more // forgiving: a separate error is logged, but the key-value pair is skipped // and execution continues. Passing an orphaned key triggers similar behavior: // panics in development and errors in production. -func (s *SugaredLogger) With(args ...interface{}) *SugaredLogger { +func (s *SugaredLogger) With(args ...any) *SugaredLogger { return &SugaredLogger{base: s.base.With(s.sweetenFields(args)...)} } // Debug uses fmt.Sprint to construct and log a message. -func (s *SugaredLogger) Debug(args ...interface{}) { +func (s *SugaredLogger) Debug(args ...any) { s.log(DebugLevel, "", args, nil) } // Info uses fmt.Sprint to construct and log a message. -func (s *SugaredLogger) Info(args ...interface{}) { +func (s *SugaredLogger) Info(args ...any) { s.log(InfoLevel, "", args, nil) } // Warn uses fmt.Sprint to construct and log a message. -func (s *SugaredLogger) Warn(args ...interface{}) { +func (s *SugaredLogger) Warn(args ...any) { s.log(WarnLevel, "", args, nil) } // Error uses fmt.Sprint to construct and log a message. -func (s *SugaredLogger) Error(args ...interface{}) { +func (s *SugaredLogger) Error(args ...any) { s.log(ErrorLevel, "", args, nil) } // DPanic uses fmt.Sprint to construct and log a message. In development, the // logger then panics. (See DPanicLevel for details.) -func (s *SugaredLogger) DPanic(args ...interface{}) { +func (s *SugaredLogger) DPanic(args ...any) { s.log(DPanicLevel, "", args, nil) } // Panic uses fmt.Sprint to construct and log a message, then panics. -func (s *SugaredLogger) Panic(args ...interface{}) { +func (s *SugaredLogger) Panic(args ...any) { s.log(PanicLevel, "", args, nil) } // Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit. -func (s *SugaredLogger) Fatal(args ...interface{}) { +func (s *SugaredLogger) Fatal(args ...any) { s.log(FatalLevel, "", args, nil) } // Debugf uses fmt.Sprintf to log a templated message. -func (s *SugaredLogger) Debugf(template string, args ...interface{}) { +func (s *SugaredLogger) Debugf(template string, args ...any) { s.log(DebugLevel, template, args, nil) } // Infof uses fmt.Sprintf to log a templated message. -func (s *SugaredLogger) Infof(template string, args ...interface{}) { +func (s *SugaredLogger) Infof(template string, args ...any) { s.log(InfoLevel, template, args, nil) } // Warnf uses fmt.Sprintf to log a templated message. -func (s *SugaredLogger) Warnf(template string, args ...interface{}) { +func (s *SugaredLogger) Warnf(template string, args ...any) { s.log(WarnLevel, template, args, nil) } // Errorf uses fmt.Sprintf to log a templated message. -func (s *SugaredLogger) Errorf(template string, args ...interface{}) { +func (s *SugaredLogger) Errorf(template string, args ...any) { s.log(ErrorLevel, template, args, nil) } // DPanicf uses fmt.Sprintf to log a templated message. In development, the // logger then panics. (See DPanicLevel for details.) -func (s *SugaredLogger) DPanicf(template string, args ...interface{}) { +func (s *SugaredLogger) DPanicf(template string, args ...any) { s.log(DPanicLevel, template, args, nil) } // Panicf uses fmt.Sprintf to log a templated message, then panics. -func (s *SugaredLogger) Panicf(template string, args ...interface{}) { +func (s *SugaredLogger) Panicf(template string, args ...any) { s.log(PanicLevel, template, args, nil) } // Fatalf uses fmt.Sprintf to log a templated message, then calls os.Exit. -func (s *SugaredLogger) Fatalf(template string, args ...interface{}) { +func (s *SugaredLogger) Fatalf(template string, args ...any) { s.log(FatalLevel, template, args, nil) } @@ -168,45 +171,46 @@ func (s *SugaredLogger) Fatalf(template string, args ...interface{}) { // pairs are treated as they are in With. // // When debug-level logging is disabled, this is much faster than -// s.With(keysAndValues).Debug(msg) -func (s *SugaredLogger) Debugw(msg string, keysAndValues ...interface{}) { +// +// s.With(keysAndValues).Debug(msg) +func (s *SugaredLogger) Debugw(msg string, keysAndValues ...any) { s.log(DebugLevel, msg, nil, keysAndValues) } // Infow logs a message with some additional context. The variadic key-value // pairs are treated as they are in With. -func (s *SugaredLogger) Infow(msg string, keysAndValues ...interface{}) { +func (s *SugaredLogger) Infow(msg string, keysAndValues ...any) { s.log(InfoLevel, msg, nil, keysAndValues) } // Warnw logs a message with some additional context. The variadic key-value // pairs are treated as they are in With. -func (s *SugaredLogger) Warnw(msg string, keysAndValues ...interface{}) { +func (s *SugaredLogger) Warnw(msg string, keysAndValues ...any) { s.log(WarnLevel, msg, nil, keysAndValues) } // Errorw logs a message with some additional context. The variadic key-value // pairs are treated as they are in With. -func (s *SugaredLogger) Errorw(msg string, keysAndValues ...interface{}) { +func (s *SugaredLogger) Errorw(msg string, keysAndValues ...any) { s.log(ErrorLevel, msg, nil, keysAndValues) } // DPanicw logs a message with some additional context. In development, the // logger then panics. (See DPanicLevel for details.) The variadic key-value // pairs are treated as they are in With. -func (s *SugaredLogger) DPanicw(msg string, keysAndValues ...interface{}) { +func (s *SugaredLogger) DPanicw(msg string, keysAndValues ...any) { s.log(DPanicLevel, msg, nil, keysAndValues) } // Panicw logs a message with some additional context, then panics. The // variadic key-value pairs are treated as they are in With. -func (s *SugaredLogger) Panicw(msg string, keysAndValues ...interface{}) { +func (s *SugaredLogger) Panicw(msg string, keysAndValues ...any) { s.log(PanicLevel, msg, nil, keysAndValues) } // Fatalw logs a message with some additional context, then calls os.Exit. The // variadic key-value pairs are treated as they are in With. -func (s *SugaredLogger) Fatalw(msg string, keysAndValues ...interface{}) { +func (s *SugaredLogger) Fatalw(msg string, keysAndValues ...any) { s.log(FatalLevel, msg, nil, keysAndValues) } @@ -215,7 +219,7 @@ func (s *SugaredLogger) Sync() error { return s.base.Sync() } -func (s *SugaredLogger) log(lvl zapcore.Level, template string, fmtArgs []interface{}, context []interface{}) { +func (s *SugaredLogger) log(lvl zapcore.Level, template string, fmtArgs []any, context []any) { // If logging at this level is completely disabled, skip the overhead of // string formatting. if lvl < DPanicLevel && !s.base.Core().Enabled(lvl) { @@ -235,7 +239,7 @@ func (s *SugaredLogger) log(lvl zapcore.Level, template string, fmtArgs []interf } } -func (s *SugaredLogger) sweetenFields(args []interface{}) []Field { +func (s *SugaredLogger) sweetenFields(args []any) []Field { if len(args) == 0 { return nil } @@ -283,7 +287,7 @@ func (s *SugaredLogger) sweetenFields(args []interface{}) []Field { type invalidPair struct { position int - key, value interface{} + key, value any } func (p invalidPair) MarshalLogObject(enc zapcore.ObjectEncoder) error { diff --git a/vendor/go.uber.org/zap/zapcore/console_encoder.go b/vendor/go.uber.org/zap/zapcore/console_encoder.go index b7875966f..bcf48afcc 100644 --- a/vendor/go.uber.org/zap/zapcore/console_encoder.go +++ b/vendor/go.uber.org/zap/zapcore/console_encoder.go @@ -29,8 +29,8 @@ import ( ) var _sliceEncoderPool = sync.Pool{ - New: func() interface{} { - return &sliceArrayEncoder{elems: make([]interface{}, 0, 2)} + New: func() any { + return &sliceArrayEncoder{elems: make([]any, 0, 2)} }, } diff --git a/vendor/go.uber.org/zap/zapcore/encoder.go b/vendor/go.uber.org/zap/zapcore/encoder.go index 6c78f7e49..60c40c070 100644 --- a/vendor/go.uber.org/zap/zapcore/encoder.go +++ b/vendor/go.uber.org/zap/zapcore/encoder.go @@ -326,7 +326,7 @@ type ObjectEncoder interface { // AddReflected uses reflection to serialize arbitrary objects, so it can be // slow and allocation-heavy. - AddReflected(key string, value interface{}) error + AddReflected(key string, value any) error // OpenNamespace opens an isolated namespace where all subsequent fields will // be added. Applications can use namespaces to prevent key collisions when // injecting loggers into sub-components or third-party libraries. @@ -351,7 +351,7 @@ type ArrayEncoder interface { // AppendReflected uses reflection to serialize arbitrary objects, so it's // slow and allocation-heavy. - AppendReflected(value interface{}) error + AppendReflected(value any) error } // PrimitiveArrayEncoder is the subset of the ArrayEncoder interface that deals diff --git a/vendor/go.uber.org/zap/zapcore/entry.go b/vendor/go.uber.org/zap/zapcore/entry.go index 8273abdf0..e07916a50 100644 --- a/vendor/go.uber.org/zap/zapcore/entry.go +++ b/vendor/go.uber.org/zap/zapcore/entry.go @@ -33,7 +33,7 @@ import ( ) var ( - _cePool = sync.Pool{New: func() interface{} { + _cePool = sync.Pool{New: func() any { // Pre-allocate some space for cores. return &CheckedEntry{ cores: make([]Core, 4), diff --git a/vendor/go.uber.org/zap/zapcore/error.go b/vendor/go.uber.org/zap/zapcore/error.go index 9ba2272c3..04d1f7c51 100644 --- a/vendor/go.uber.org/zap/zapcore/error.go +++ b/vendor/go.uber.org/zap/zapcore/error.go @@ -35,13 +35,13 @@ import ( // causer (from github.com/pkg/errors), a ${key}Causes field is added with an // array of objects containing the errors this error was comprised of. // -// { -// "error": err.Error(), -// "errorVerbose": fmt.Sprintf("%+v", err), -// "errorCauses": [ -// ... -// ], -// } +// { +// "error": err.Error(), +// "errorVerbose": fmt.Sprintf("%+v", err), +// "errorCauses": [ +// ... +// ], +// } func encodeError(key string, err error, enc ObjectEncoder) error { basic := err.Error() enc.AddString(key, basic) @@ -86,7 +86,7 @@ func (errs errArray) MarshalLogArray(arr ArrayEncoder) error { return nil } -var _errArrayElemPool = sync.Pool{New: func() interface{} { +var _errArrayElemPool = sync.Pool{New: func() any { return &errArrayElem{} }} diff --git a/vendor/go.uber.org/zap/zapcore/field.go b/vendor/go.uber.org/zap/zapcore/field.go index ae772e4a1..1d6b787c7 100644 --- a/vendor/go.uber.org/zap/zapcore/field.go +++ b/vendor/go.uber.org/zap/zapcore/field.go @@ -99,7 +99,7 @@ type Field struct { Type FieldType Integer int64 String string - Interface interface{} + Interface any } // AddTo exports a field through the ObjectEncoder interface. It's primarily @@ -200,7 +200,7 @@ func addFields(enc ObjectEncoder, fields []Field) { } } -func encodeStringer(key string, stringer interface{}, enc ObjectEncoder) (err error) { +func encodeStringer(key string, stringer any, enc ObjectEncoder) (err error) { defer func() { if v := recover(); v != nil { err = fmt.Errorf("PANIC=%v", v) diff --git a/vendor/go.uber.org/zap/zapcore/json_encoder.go b/vendor/go.uber.org/zap/zapcore/json_encoder.go index 7facc1b36..250768c5c 100644 --- a/vendor/go.uber.org/zap/zapcore/json_encoder.go +++ b/vendor/go.uber.org/zap/zapcore/json_encoder.go @@ -35,7 +35,7 @@ import ( // For JSON-escaping; see jsonEncoder.safeAddString below. const _hex = "0123456789abcdef" -var _jsonPool = sync.Pool{New: func() interface{} { +var _jsonPool = sync.Pool{New: func() any { return &jsonEncoder{} }} @@ -72,7 +72,9 @@ type jsonEncoder struct { // // Note that the encoder doesn't deduplicate keys, so it's possible to produce // a message like -// {"foo":"bar","foo":"baz"} +// +// {"foo":"bar","foo":"baz"} +// // This is permitted by the JSON specification, but not encouraged. Many // libraries will ignore duplicate key-value pairs (typically keeping the last // pair) when unmarshaling, but users should attempt to avoid adding duplicate @@ -149,7 +151,7 @@ var nullLiteralBytes = []byte("null") // Only invoke the standard JSON encoder if there is actually something to // encode; otherwise write JSON null literal directly. -func (enc *jsonEncoder) encodeReflected(obj interface{}) ([]byte, error) { +func (enc *jsonEncoder) encodeReflected(obj any) ([]byte, error) { if obj == nil { return nullLiteralBytes, nil } @@ -161,7 +163,7 @@ func (enc *jsonEncoder) encodeReflected(obj interface{}) ([]byte, error) { return enc.reflectBuf.Bytes(), nil } -func (enc *jsonEncoder) AddReflected(key string, obj interface{}) error { +func (enc *jsonEncoder) AddReflected(key string, obj any) error { valueBytes, err := enc.encodeReflected(obj) if err != nil { return err @@ -249,7 +251,7 @@ func (enc *jsonEncoder) AppendInt64(val int64) { enc.buf.AppendInt(val) } -func (enc *jsonEncoder) AppendReflected(val interface{}) error { +func (enc *jsonEncoder) AppendReflected(val any) error { valueBytes, err := enc.encodeReflected(val) if err != nil { return err diff --git a/vendor/go.uber.org/zap/zapcore/level.go b/vendor/go.uber.org/zap/zapcore/level.go index e575c9f43..34404bcec 100644 --- a/vendor/go.uber.org/zap/zapcore/level.go +++ b/vendor/go.uber.org/zap/zapcore/level.go @@ -151,7 +151,7 @@ func (l *Level) Set(s string) error { } // Get gets the level for the flag.Getter interface. -func (l *Level) Get() interface{} { +func (l *Level) Get() any { return *l } diff --git a/vendor/go.uber.org/zap/zapcore/memory_encoder.go b/vendor/go.uber.org/zap/zapcore/memory_encoder.go index dfead0829..fc6afbaf2 100644 --- a/vendor/go.uber.org/zap/zapcore/memory_encoder.go +++ b/vendor/go.uber.org/zap/zapcore/memory_encoder.go @@ -27,14 +27,14 @@ import "time" // helpful in tests. type MapObjectEncoder struct { // Fields contains the entire encoded log context. - Fields map[string]interface{} + Fields map[string]any // cur is a pointer to the namespace we're currently writing to. - cur map[string]interface{} + cur map[string]any } // NewMapObjectEncoder creates a new map-backed ObjectEncoder. func NewMapObjectEncoder() *MapObjectEncoder { - m := make(map[string]interface{}) + m := make(map[string]any) return &MapObjectEncoder{ Fields: m, cur: m, @@ -43,7 +43,7 @@ func NewMapObjectEncoder() *MapObjectEncoder { // AddArray implements ObjectEncoder. func (m *MapObjectEncoder) AddArray(key string, v ArrayMarshaler) error { - arr := &sliceArrayEncoder{elems: make([]interface{}, 0)} + arr := &sliceArrayEncoder{elems: make([]any, 0)} err := v.MarshalLogArray(arr) m.cur[key] = arr.elems return err @@ -120,14 +120,14 @@ func (m *MapObjectEncoder) AddUint8(k string, v uint8) { m.cur[k] = v } func (m *MapObjectEncoder) AddUintptr(k string, v uintptr) { m.cur[k] = v } // AddReflected implements ObjectEncoder. -func (m *MapObjectEncoder) AddReflected(k string, v interface{}) error { +func (m *MapObjectEncoder) AddReflected(k string, v any) error { m.cur[k] = v return nil } // OpenNamespace implements ObjectEncoder. func (m *MapObjectEncoder) OpenNamespace(k string) { - ns := make(map[string]interface{}) + ns := make(map[string]any) m.cur[k] = ns m.cur = ns } @@ -135,7 +135,7 @@ func (m *MapObjectEncoder) OpenNamespace(k string) { // sliceArrayEncoder is an ArrayEncoder backed by a simple []interface{}. Like // the MapObjectEncoder, it's not designed for production use. type sliceArrayEncoder struct { - elems []interface{} + elems []any } func (s *sliceArrayEncoder) AppendArray(v ArrayMarshaler) error { @@ -152,7 +152,7 @@ func (s *sliceArrayEncoder) AppendObject(v ObjectMarshaler) error { return err } -func (s *sliceArrayEncoder) AppendReflected(v interface{}) error { +func (s *sliceArrayEncoder) AppendReflected(v any) error { s.elems = append(s.elems, v) return nil } diff --git a/vendor/golang.org/x/net/context/go17.go b/vendor/golang.org/x/net/context/go17.go index d20f52b7d..c50ba88b2 100644 --- a/vendor/golang.org/x/net/context/go17.go +++ b/vendor/golang.org/x/net/context/go17.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build go1.7 // +build go1.7 package context @@ -53,11 +54,11 @@ func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { // Canceling this context releases resources associated with it, so code should // call cancel as soon as the operations running in this Context complete: // -// func slowOperationWithTimeout(ctx context.Context) (Result, error) { -// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) -// defer cancel() // releases resources if slowOperation completes before timeout elapses -// return slowOperation(ctx) -// } +// func slowOperationWithTimeout(ctx context.Context) (Result, error) { +// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) +// defer cancel() // releases resources if slowOperation completes before timeout elapses +// return slowOperation(ctx) +// } func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { return WithDeadline(parent, time.Now().Add(timeout)) } @@ -67,6 +68,6 @@ func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { // // Use context Values only for request-scoped data that transits processes and // APIs, not for passing optional parameters to functions. -func WithValue(parent Context, key interface{}, val interface{}) Context { +func WithValue(parent Context, key any, val any) Context { return context.WithValue(parent, key, val) } diff --git a/vendor/golang.org/x/net/context/pre_go17.go b/vendor/golang.org/x/net/context/pre_go17.go index 0f35592df..35f560861 100644 --- a/vendor/golang.org/x/net/context/pre_go17.go +++ b/vendor/golang.org/x/net/context/pre_go17.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !go1.7 // +build !go1.7 package context @@ -29,7 +30,7 @@ func (*emptyCtx) Err() error { return nil } -func (*emptyCtx) Value(key interface{}) interface{} { +func (*emptyCtx) Value(key any) any { return nil } @@ -263,11 +264,11 @@ func (c *timerCtx) cancel(removeFromParent bool, err error) { // Canceling this context releases resources associated with it, so code should // call cancel as soon as the operations running in this Context complete: // -// func slowOperationWithTimeout(ctx context.Context) (Result, error) { -// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) -// defer cancel() // releases resources if slowOperation completes before timeout elapses -// return slowOperation(ctx) -// } +// func slowOperationWithTimeout(ctx context.Context) (Result, error) { +// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) +// defer cancel() // releases resources if slowOperation completes before timeout elapses +// return slowOperation(ctx) +// } func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { return WithDeadline(parent, time.Now().Add(timeout)) } @@ -277,7 +278,7 @@ func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { // // Use context Values only for request-scoped data that transits processes and // APIs, not for passing optional parameters to functions. -func WithValue(parent Context, key interface{}, val interface{}) Context { +func WithValue(parent Context, key any, val any) Context { return &valueCtx{parent, key, val} } @@ -285,14 +286,14 @@ func WithValue(parent Context, key interface{}, val interface{}) Context { // delegates all other calls to the embedded Context. type valueCtx struct { Context - key, val interface{} + key, val any } func (c *valueCtx) String() string { return fmt.Sprintf("%v.WithValue(%#v, %#v)", c.Context, c.key, c.val) } -func (c *valueCtx) Value(key interface{}) interface{} { +func (c *valueCtx) Value(key any) any { if c.key == key { return c.val } diff --git a/vendor/golang.org/x/net/context/pre_go19.go b/vendor/golang.org/x/net/context/pre_go19.go index b105f80be..165e35649 100644 --- a/vendor/golang.org/x/net/context/pre_go19.go +++ b/vendor/golang.org/x/net/context/pre_go19.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !go1.9 // +build !go1.9 package context @@ -100,7 +101,7 @@ type Context interface { // u, ok := ctx.Value(userKey).(*User) // return u, ok // } - Value(key interface{}) interface{} + Value(key any) any } // A CancelFunc tells an operation to abandon its work. diff --git a/vendor/golang.org/x/net/http2/databuffer.go b/vendor/golang.org/x/net/http2/databuffer.go index a3067f8de..dbe458608 100644 --- a/vendor/golang.org/x/net/http2/databuffer.go +++ b/vendor/golang.org/x/net/http2/databuffer.go @@ -29,11 +29,11 @@ var ( 16 << 10, } dataChunkPools = [...]sync.Pool{ - {New: func() interface{} { return make([]byte, 1<<10) }}, - {New: func() interface{} { return make([]byte, 2<<10) }}, - {New: func() interface{} { return make([]byte, 4<<10) }}, - {New: func() interface{} { return make([]byte, 8<<10) }}, - {New: func() interface{} { return make([]byte, 16<<10) }}, + {New: func() any { return make([]byte, 1<<10) }}, + {New: func() any { return make([]byte, 2<<10) }}, + {New: func() any { return make([]byte, 4<<10) }}, + {New: func() any { return make([]byte, 8<<10) }}, + {New: func() any { return make([]byte, 16<<10) }}, } ) diff --git a/vendor/golang.org/x/net/http2/frame.go b/vendor/golang.org/x/net/http2/frame.go index 514c126c5..e0e14e2fe 100644 --- a/vendor/golang.org/x/net/http2/frame.go +++ b/vendor/golang.org/x/net/http2/frame.go @@ -219,7 +219,7 @@ func (h *FrameHeader) invalidate() { h.valid = false } // frame header bytes. // Used only by ReadFrameHeader. var fhBytes = sync.Pool{ - New: func() interface{} { + New: func() any { buf := make([]byte, frameHeaderLen) return &buf }, @@ -321,8 +321,8 @@ type Framer struct { debugFramer *Framer // only use for logging written writes debugFramerBuf *bytes.Buffer - debugReadLoggerf func(string, ...interface{}) - debugWriteLoggerf func(string, ...interface{}) + debugReadLoggerf func(string, ...any) + debugWriteLoggerf func(string, ...any) frameCache *frameCache // nil if frames aren't reused (default) } diff --git a/vendor/golang.org/x/net/http2/gotrack.go b/vendor/golang.org/x/net/http2/gotrack.go index 9933c9f8c..4c3e70081 100644 --- a/vendor/golang.org/x/net/http2/gotrack.go +++ b/vendor/golang.org/x/net/http2/gotrack.go @@ -68,7 +68,7 @@ func curGoroutineID() uint64 { } var littleBuf = sync.Pool{ - New: func() interface{} { + New: func() any { buf := make([]byte, 64) return &buf }, diff --git a/vendor/golang.org/x/net/http2/hpack/huffman.go b/vendor/golang.org/x/net/http2/hpack/huffman.go index b412a96c5..de6e5baea 100644 --- a/vendor/golang.org/x/net/http2/hpack/huffman.go +++ b/vendor/golang.org/x/net/http2/hpack/huffman.go @@ -12,7 +12,7 @@ import ( ) var bufPool = sync.Pool{ - New: func() interface{} { return new(bytes.Buffer) }, + New: func() any { return new(bytes.Buffer) }, } // HuffmanDecode decodes the string in v and writes the expanded diff --git a/vendor/golang.org/x/net/http2/http2.go b/vendor/golang.org/x/net/http2/http2.go index bdaba1d46..da323e1c5 100644 --- a/vendor/golang.org/x/net/http2/http2.go +++ b/vendor/golang.org/x/net/http2/http2.go @@ -13,7 +13,6 @@ // See https://http2.github.io/ for more information on HTTP/2. // // See https://http2.golang.org/ for a test server running this code. -// package http2 // import "golang.org/x/net/http2" import ( @@ -182,10 +181,11 @@ var ( // name (key). See httpguts.ValidHeaderName for the base rules. // // Further, http2 says: -// "Just as in HTTP/1.x, header field names are strings of ASCII -// characters that are compared in a case-insensitive -// fashion. However, header field names MUST be converted to -// lowercase prior to their encoding in HTTP/2. " +// +// "Just as in HTTP/1.x, header field names are strings of ASCII +// characters that are compared in a case-insensitive +// fashion. However, header field names MUST be converted to +// lowercase prior to their encoding in HTTP/2. " func validWireHeaderFieldName(v string) bool { if len(v) == 0 { return false @@ -264,7 +264,7 @@ func newBufferedWriter(w io.Writer) *bufferedWriter { const bufWriterPoolBufferSize = 4 << 10 var bufWriterPool = sync.Pool{ - New: func() interface{} { + New: func() any { return bufio.NewWriterSize(nil, bufWriterPoolBufferSize) }, } @@ -333,7 +333,7 @@ type connectionStater interface { ConnectionState() tls.ConnectionState } -var sorterPool = sync.Pool{New: func() interface{} { return new(sorter) }} +var sorterPool = sync.Pool{New: func() any { return new(sorter) }} type sorter struct { v []string // owned by sorter @@ -369,8 +369,8 @@ func (s *sorter) SortStrings(ss []string) { // validPseudoPath reports whether v is a valid :path pseudo-header // value. It must be either: // -// *) a non-empty string starting with '/' -// *) the string '*', for OPTIONS requests. +// *) a non-empty string starting with '/' +// *) the string '*', for OPTIONS requests. // // For now this is only used a quick check for deciding when to clean // up Opaque URLs before sending requests from the Transport. diff --git a/vendor/golang.org/x/net/http2/server.go b/vendor/golang.org/x/net/http2/server.go index 5e01ce9ab..110f2416e 100644 --- a/vendor/golang.org/x/net/http2/server.go +++ b/vendor/golang.org/x/net/http2/server.go @@ -67,7 +67,7 @@ var ( ) var responseWriterStatePool = sync.Pool{ - New: func() interface{} { + New: func() any { rws := &responseWriterState{} rws.bw = bufio.NewWriterSize(chunkWriter{rws}, handlerChunkWriteSize) return rws @@ -79,7 +79,7 @@ var ( testHookOnConn func() testHookGetServerConn func(*serverConn) testHookOnPanicMu *sync.Mutex // nil except in tests - testHookOnPanic func(sc *serverConn, panicVal interface{}) (rePanic bool) + testHookOnPanic func(sc *serverConn, panicVal any) (rePanic bool) ) // Server is an HTTP/2 server. @@ -376,7 +376,7 @@ func (s *Server) ServeConn(c net.Conn, opts *ServeConnOpts) { streams: make(map[uint32]*stream), readFrameCh: make(chan readFrameResult), wantWriteFrameCh: make(chan FrameWriteRequest, 8), - serveMsgCh: make(chan interface{}, 8), + serveMsgCh: make(chan any, 8), wroteFrameCh: make(chan frameWriteResult, 1), // buffered; one send in writeFrameAsync bodyReadCh: make(chan bodyReadMsg), // buffering doesn't matter either way doneServing: make(chan struct{}), @@ -503,7 +503,7 @@ type serverConn struct { wantWriteFrameCh chan FrameWriteRequest // from handlers -> serve wroteFrameCh chan frameWriteResult // from writeFrameAsync -> serve, tickles more frame writes bodyReadCh chan bodyReadMsg // from handlers -> serve - serveMsgCh chan interface{} // misc messages & code to send to / run on the serve loop + serveMsgCh chan any // misc messages & code to send to / run on the serve loop flow flow // conn-wide (not stream-specific) outbound flow control inflow flow // conn-wide inbound flow control tlsState *tls.ConnectionState // shared by all handlers, like net/http @@ -638,13 +638,13 @@ func (sc *serverConn) setConnState(state http.ConnState) { } } -func (sc *serverConn) vlogf(format string, args ...interface{}) { +func (sc *serverConn) vlogf(format string, args ...any) { if VerboseLogs { sc.logf(format, args...) } } -func (sc *serverConn) logf(format string, args ...interface{}) { +func (sc *serverConn) logf(format string, args ...any) { if lg := sc.hs.ErrorLog; lg != nil { lg.Printf(format, args...) } else { @@ -696,7 +696,7 @@ func isClosedConnError(err error) bool { return false } -func (sc *serverConn) condlogf(err error, format string, args ...interface{}) { +func (sc *serverConn) condlogf(err error, format string, args ...any) { if err == nil { return } @@ -946,7 +946,7 @@ func (sc *serverConn) onSettingsTimer() { sc.sendServeMsg(settingsTimerMsg) } func (sc *serverConn) onIdleTimer() { sc.sendServeMsg(idleTimerMsg) } func (sc *serverConn) onShutdownTimer() { sc.sendServeMsg(shutdownTimerMsg) } -func (sc *serverConn) sendServeMsg(msg interface{}) { +func (sc *serverConn) sendServeMsg(msg any) { sc.serveG.checkNotOn() // NOT select { case sc.serveMsgCh <- msg: @@ -988,11 +988,11 @@ func (sc *serverConn) readPreface() error { } var errChanPool = sync.Pool{ - New: func() interface{} { return make(chan error, 1) }, + New: func() any { return make(chan error, 1) }, } var writeDataPool = sync.Pool{ - New: func() interface{} { return new(writeData) }, + New: func() any { return new(writeData) }, } // writeDataFromHandler writes DATA response frames from a handler on @@ -2507,8 +2507,9 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) { // prior to the headers being written. If the set of trailers is fixed // or known before the header is written, the normal Go trailers mechanism // is preferred: -// https://golang.org/pkg/net/http/#ResponseWriter -// https://golang.org/pkg/net/http/#example_ResponseWriter_trailers +// +// https://golang.org/pkg/net/http/#ResponseWriter +// https://golang.org/pkg/net/http/#example_ResponseWriter_trailers const TrailerPrefix = "Trailer:" // promoteUndeclaredTrailers permits http.Handlers to set trailers @@ -2950,7 +2951,7 @@ func new400Handler(err error) http.HandlerFunc { // disabled. See comments on h1ServerShutdownChan above for why // the code is written this way. func h1ServerKeepAlivesDisabled(hs *http.Server) bool { - var x interface{} = hs + var x any = hs type I interface { doKeepAlives() bool } diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go index aeac7d8a5..af4cbb1d8 100644 --- a/vendor/golang.org/x/net/http2/transport.go +++ b/vendor/golang.org/x/net/http2/transport.go @@ -2373,21 +2373,21 @@ var ( errPseudoTrailers = errors.New("http2: invalid pseudo header in trailers") ) -func (cc *ClientConn) logf(format string, args ...interface{}) { +func (cc *ClientConn) logf(format string, args ...any) { cc.t.logf(format, args...) } -func (cc *ClientConn) vlogf(format string, args ...interface{}) { +func (cc *ClientConn) vlogf(format string, args ...any) { cc.t.vlogf(format, args...) } -func (t *Transport) vlogf(format string, args ...interface{}) { +func (t *Transport) vlogf(format string, args ...any) { if VerboseLogs { t.logf(format, args...) } } -func (t *Transport) logf(format string, args ...interface{}) { +func (t *Transport) logf(format string, args ...any) { log.Printf(format, args...) } diff --git a/vendor/golang.org/x/net/trace/events.go b/vendor/golang.org/x/net/trace/events.go index c646a6952..4aa118fff 100644 --- a/vendor/golang.org/x/net/trace/events.go +++ b/vendor/golang.org/x/net/trace/events.go @@ -117,10 +117,10 @@ func parseEventsArgs(req *http.Request) (fam string, b int, ok bool) { type EventLog interface { // Printf formats its arguments with fmt.Sprintf and adds the // result to the event log. - Printf(format string, a ...interface{}) + Printf(format string, a ...any) // Errorf is like Printf, but it marks this event as an error. - Errorf(format string, a ...interface{}) + Errorf(format string, a ...any) // Finish declares that this event log is complete. // The event log should not be used after calling this method. @@ -302,15 +302,15 @@ func (el *eventLog) delta(t time.Time) (time.Duration, bool) { } -func (el *eventLog) Printf(format string, a ...interface{}) { +func (el *eventLog) Printf(format string, a ...any) { el.printf(false, format, a...) } -func (el *eventLog) Errorf(format string, a ...interface{}) { +func (el *eventLog) Errorf(format string, a ...any) { el.printf(true, format, a...) } -func (el *eventLog) printf(isErr bool, format string, a ...interface{}) { +func (el *eventLog) printf(isErr bool, format string, a ...any) { e := logEntry{When: time.Now(), IsErr: isErr, What: fmt.Sprintf(format, a...)} el.mu.Lock() e.Elapsed, e.NewDay = el.delta(e.When) diff --git a/vendor/golang.org/x/net/trace/trace.go b/vendor/golang.org/x/net/trace/trace.go index 3ebf6f2da..807e40516 100644 --- a/vendor/golang.org/x/net/trace/trace.go +++ b/vendor/golang.org/x/net/trace/trace.go @@ -323,7 +323,7 @@ type Trace interface { // LazyPrintf evaluates its arguments with fmt.Sprintf each time the // /debug/requests page is rendered. Any memory referenced by a will be // pinned until the trace is finished and later discarded. - LazyPrintf(format string, a ...interface{}) + LazyPrintf(format string, a ...any) // SetError declares that this trace resulted in an error. SetError() @@ -332,7 +332,7 @@ type Trace interface { // f will be called for each event passed to LazyLog at a time when // it is no longer required, whether while the trace is still active // and the event is discarded, or when a completed trace is discarded. - SetRecycler(f func(interface{})) + SetRecycler(f func(any)) // SetTraceInfo sets the trace info for the trace. // This is currently unused. @@ -350,7 +350,7 @@ type Trace interface { type lazySprintf struct { format string - a []interface{} + a []any } func (l *lazySprintf) String() string { @@ -689,7 +689,7 @@ type event struct { NewDay bool // whether this event is on a different day to the previous event Recyclable bool // whether this event was passed via LazyLog Sensitive bool // whether this event contains sensitive information - What interface{} // string or fmt.Stringer + What any // string or fmt.Stringer } // WhenString returns a string representation of the elapsed time of the event. @@ -724,7 +724,7 @@ type trace struct { mu sync.RWMutex events []event // Append-only sequence of events (modulo discards). maxEvents int - recycler func(interface{}) + recycler func(any) IsError bool // Whether this trace resulted in an error. Elapsed time.Duration // Elapsed time for this trace, zero while active. traceID uint64 // Trace information if non-zero. @@ -773,7 +773,7 @@ func (tr *trace) delta(t time.Time) (time.Duration, bool) { return t.Sub(prev), prev.Day() != t.Day() } -func (tr *trace) addEvent(x interface{}, recyclable, sensitive bool) { +func (tr *trace) addEvent(x any, recyclable, sensitive bool) { if DebugUseAfterFinish && tr.finishStack != nil { buf := make([]byte, 4<<10) // 4 KB should be enough n := runtime.Stack(buf, false) @@ -830,7 +830,7 @@ func (tr *trace) LazyLog(x fmt.Stringer, sensitive bool) { tr.addEvent(x, true, sensitive) } -func (tr *trace) LazyPrintf(format string, a ...interface{}) { +func (tr *trace) LazyPrintf(format string, a ...any) { tr.addEvent(&lazySprintf{format, a}, false, false) } @@ -840,7 +840,7 @@ func (tr *trace) SetError() { tr.mu.Unlock() } -func (tr *trace) SetRecycler(f func(interface{})) { +func (tr *trace) SetRecycler(f func(any)) { tr.mu.Lock() tr.recycler = f tr.mu.Unlock() @@ -870,7 +870,7 @@ func (tr *trace) unref() { tr.mu.RLock() if tr.recycler != nil { // freeTrace clears tr, so we hold tr.recycler and tr.events here. - go func(f func(interface{}), es []event) { + go func(f func(any), es []event) { for _, e := range es { if e.Recyclable { f(e.What) diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go index 053d664d0..9af72c50b 100644 --- a/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -122,14 +122,14 @@ func Getpagesize() int { return 4096 } // NewCallback converts a Go function to a function pointer conforming to the stdcall calling convention. // This is useful when interoperating with Windows code requiring callbacks. // The argument is expected to be a function with with one uintptr-sized result. The function must not have arguments with size larger than the size of uintptr. -func NewCallback(fn interface{}) uintptr { +func NewCallback(fn any) uintptr { return syscall.NewCallback(fn) } // NewCallbackCDecl converts a Go function to a function pointer conforming to the cdecl calling convention. // This is useful when interoperating with Windows code requiring callbacks. // The argument is expected to be a function with with one uintptr-sized result. The function must not have arguments with size larger than the size of uintptr. -func NewCallbackCDecl(fn interface{}) uintptr { +func NewCallbackCDecl(fn any) uintptr { return syscall.NewCallbackCDecl(fn) } diff --git a/vendor/golang.org/x/time/rate/rate.go b/vendor/golang.org/x/time/rate/rate.go index 7228d97e9..45d38da41 100644 --- a/vendor/golang.org/x/time/rate/rate.go +++ b/vendor/golang.org/x/time/rate/rate.go @@ -197,13 +197,15 @@ func (lim *Limiter) Reserve() *Reservation { // The Limiter takes this Reservation into account when allowing future events. // ReserveN returns false if n exceeds the Limiter's burst size. // Usage example: -// r := lim.ReserveN(time.Now(), 1) -// if !r.OK() { -// // Not allowed to act! Did you remember to set lim.burst to be > 0 ? -// return -// } -// time.Sleep(r.Delay()) -// Act() +// +// r := lim.ReserveN(time.Now(), 1) +// if !r.OK() { +// // Not allowed to act! Did you remember to set lim.burst to be > 0 ? +// return +// } +// time.Sleep(r.Delay()) +// Act() +// // Use this method if you wish to wait and slow down in accordance with the rate limit without dropping events. // If you need to respect a deadline or cancel the delay, use Wait instead. // To drop or skip events exceeding rate limit, use Allow instead. @@ -220,7 +222,7 @@ type contextContext interface { Deadline() (deadline time.Time, ok bool) Done() <-chan struct{} Err() error - Value(key interface{}) interface{} + Value(key any) any } // Wait is shorthand for WaitN(ctx, 1). diff --git a/vendor/google.golang.org/grpc/attributes/attributes.go b/vendor/google.golang.org/grpc/attributes/attributes.go index 68ffc6201..c7cf8bc82 100644 --- a/vendor/google.golang.org/grpc/attributes/attributes.go +++ b/vendor/google.golang.org/grpc/attributes/attributes.go @@ -28,17 +28,17 @@ import "fmt" // key/value pairs. Keys must be hashable, and users should define their own // types for keys. type Attributes struct { - m map[interface{}]interface{} + m map[any]any } // New returns a new Attributes containing all key/value pairs in kvs. If the // same key appears multiple times, the last value overwrites all previous // values for that key. Panics if len(kvs) is not even. -func New(kvs ...interface{}) *Attributes { +func New(kvs ...any) *Attributes { if len(kvs)%2 != 0 { panic(fmt.Sprintf("attributes.New called with unexpected input: len(kvs) = %v", len(kvs))) } - a := &Attributes{m: make(map[interface{}]interface{}, len(kvs)/2)} + a := &Attributes{m: make(map[any]any, len(kvs)/2)} for i := 0; i < len(kvs)/2; i++ { a.m[kvs[i*2]] = kvs[i*2+1] } @@ -49,11 +49,11 @@ func New(kvs ...interface{}) *Attributes { // kvs. Panics if len(kvs) is not even. If the same key appears multiple // times, the last value overwrites all previous values for that key. To // remove an existing key, use a nil value. -func (a *Attributes) WithValues(kvs ...interface{}) *Attributes { +func (a *Attributes) WithValues(kvs ...any) *Attributes { if len(kvs)%2 != 0 { panic(fmt.Sprintf("attributes.New called with unexpected input: len(kvs) = %v", len(kvs))) } - n := &Attributes{m: make(map[interface{}]interface{}, len(a.m)+len(kvs)/2)} + n := &Attributes{m: make(map[any]any, len(a.m)+len(kvs)/2)} for k, v := range a.m { n.m[k] = v } @@ -65,6 +65,6 @@ func (a *Attributes) WithValues(kvs ...interface{}) *Attributes { // Value returns the value associated with these attributes for key, or nil if // no value is associated with key. -func (a *Attributes) Value(key interface{}) interface{} { +func (a *Attributes) Value(key any) any { return a.m[key] } diff --git a/vendor/google.golang.org/grpc/balancer.go b/vendor/google.golang.org/grpc/balancer.go index a8eb0f476..8e24bbe67 100644 --- a/vendor/google.golang.org/grpc/balancer.go +++ b/vendor/google.golang.org/grpc/balancer.go @@ -38,7 +38,7 @@ type Address struct { Addr string // Metadata is the information associated with Addr, which may be used // to make load balancing decision. - Metadata interface{} + Metadata any } // BalancerConfig specifies the configurations for Balancer. diff --git a/vendor/google.golang.org/grpc/balancer/balancer.go b/vendor/google.golang.org/grpc/balancer/balancer.go index 531a174a8..be9e987fb 100644 --- a/vendor/google.golang.org/grpc/balancer/balancer.go +++ b/vendor/google.golang.org/grpc/balancer/balancer.go @@ -232,7 +232,7 @@ type DoneInfo struct { // trailing metadata. // // The only supported type now is *orca_v1.LoadReport. - ServerLoad interface{} + ServerLoad any } var ( @@ -431,9 +431,9 @@ type ConnectivityStateEvaluator struct { // RecordTransition records state change happening in subConn and based on that // it evaluates what aggregated state should be. // -// - If at least one SubConn in Ready, the aggregated state is Ready; -// - Else if at least one SubConn in Connecting, the aggregated state is Connecting; -// - Else the aggregated state is TransientFailure. +// - If at least one SubConn in Ready, the aggregated state is Ready; +// - Else if at least one SubConn in Connecting, the aggregated state is Connecting; +// - Else the aggregated state is TransientFailure. // // Idle and Shutdown are not considered. func (cse *ConnectivityStateEvaluator) RecordTransition(oldState, newState connectivity.State) connectivity.State { diff --git a/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go b/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go index f393bb661..f09129103 100644 --- a/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go +++ b/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go @@ -318,8 +318,8 @@ func (m *GrpcLogEntry) GetPeer() *Address { } // XXX_OneofFuncs is for the internal use of the proto package. -func (*GrpcLogEntry) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _GrpcLogEntry_OneofMarshaler, _GrpcLogEntry_OneofUnmarshaler, _GrpcLogEntry_OneofSizer, []interface{}{ +func (*GrpcLogEntry) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []any) { + return _GrpcLogEntry_OneofMarshaler, _GrpcLogEntry_OneofUnmarshaler, _GrpcLogEntry_OneofSizer, []any{ (*GrpcLogEntry_ClientHeader)(nil), (*GrpcLogEntry_ServerHeader)(nil), (*GrpcLogEntry_Message)(nil), @@ -666,12 +666,12 @@ func (m *Message) GetData() []byte { // Header keys added by gRPC are omitted. To be more specific, // implementations will not log the following entries, and this is // not to be treated as a truncation: -// - entries handled by grpc that are not user visible, such as those -// that begin with 'grpc-' (with exception of grpc-trace-bin) -// or keys like 'lb-token' -// - transport specific entries, including but not limited to: -// ':path', ':authority', 'content-encoding', 'user-agent', 'te', etc -// - entries added for call credentials +// - entries handled by grpc that are not user visible, such as those +// that begin with 'grpc-' (with exception of grpc-trace-bin) +// or keys like 'lb-token' +// - transport specific entries, including but not limited to: +// ':path', ':authority', 'content-encoding', 'user-agent', 'te', etc +// - entries added for call credentials // // Implementations must always log grpc-trace-bin if it is present. // Practically speaking it will only be visible on server side because diff --git a/vendor/google.golang.org/grpc/call.go b/vendor/google.golang.org/grpc/call.go index 9e20e4d38..788c89c16 100644 --- a/vendor/google.golang.org/grpc/call.go +++ b/vendor/google.golang.org/grpc/call.go @@ -26,7 +26,7 @@ import ( // received. This is typically called by generated code. // // All errors returned by Invoke are compatible with the status package. -func (cc *ClientConn) Invoke(ctx context.Context, method string, args, reply interface{}, opts ...CallOption) error { +func (cc *ClientConn) Invoke(ctx context.Context, method string, args, reply any, opts ...CallOption) error { // allow interceptor to see all applicable call options, which means those // configured as defaults from dial option as well as per-call options opts = combine(cc.dopts.callOptions, opts) @@ -56,13 +56,13 @@ func combine(o1 []CallOption, o2 []CallOption) []CallOption { // received. This is typically called by generated code. // // DEPRECATED: Use ClientConn.Invoke instead. -func Invoke(ctx context.Context, method string, args, reply interface{}, cc *ClientConn, opts ...CallOption) error { +func Invoke(ctx context.Context, method string, args, reply any, cc *ClientConn, opts ...CallOption) error { return cc.Invoke(ctx, method, args, reply, opts...) } var unaryStreamDesc = &StreamDesc{ServerStreams: false, ClientStreams: false} -func invoke(ctx context.Context, method string, req, reply interface{}, cc *ClientConn, opts ...CallOption) error { +func invoke(ctx context.Context, method string, req, reply any, cc *ClientConn, opts ...CallOption) error { cs, err := newClientStream(ctx, unaryStreamDesc, cc, method, opts...) if err != nil { return err diff --git a/vendor/google.golang.org/grpc/clientconn.go b/vendor/google.golang.org/grpc/clientconn.go index 14ce9c76a..a5d40c851 100644 --- a/vendor/google.golang.org/grpc/clientconn.go +++ b/vendor/google.golang.org/grpc/clientconn.go @@ -345,7 +345,7 @@ func chainUnaryClientInterceptors(cc *ClientConn) { } else if len(interceptors) == 1 { chainedInt = interceptors[0] } else { - chainedInt = func(ctx context.Context, method string, req, reply interface{}, cc *ClientConn, invoker UnaryInvoker, opts ...CallOption) error { + chainedInt = func(ctx context.Context, method string, req, reply any, cc *ClientConn, invoker UnaryInvoker, opts ...CallOption) error { return interceptors[0](ctx, method, req, reply, cc, getChainUnaryInvoker(interceptors, 0, invoker), opts...) } } @@ -357,7 +357,7 @@ func getChainUnaryInvoker(interceptors []UnaryClientInterceptor, curr int, final if curr == len(interceptors)-1 { return finalInvoker } - return func(ctx context.Context, method string, req, reply interface{}, cc *ClientConn, opts ...CallOption) error { + return func(ctx context.Context, method string, req, reply any, cc *ClientConn, opts ...CallOption) error { return interceptors[curr+1](ctx, method, req, reply, cc, getChainUnaryInvoker(interceptors, curr+1, finalInvoker), opts...) } } @@ -813,9 +813,9 @@ func (ac *addrConn) connect() error { // // If ac is Ready, it checks whether current connected address of ac is in the // new addrs list. -// - If true, it updates ac.addrs and returns true. The ac will keep using -// the existing connection. -// - If false, it does nothing and returns false. +// - If true, it updates ac.addrs and returns true. The ac will keep using +// the existing connection. +// - If false, it does nothing and returns false. func (ac *addrConn) tryUpdateAddrs(addrs []resolver.Address) bool { ac.mu.Lock() defer ac.mu.Unlock() @@ -1348,7 +1348,7 @@ func (ac *addrConn) startHealthCheck(ctx context.Context) { // Set up the health check helper functions. currentTr := ac.transport - newStream := func(method string) (interface{}, error) { + newStream := func(method string) (any, error) { ac.mu.Lock() if ac.transport != currentTr { ac.mu.Unlock() diff --git a/vendor/google.golang.org/grpc/codec.go b/vendor/google.golang.org/grpc/codec.go index 129776547..411e3dfd4 100644 --- a/vendor/google.golang.org/grpc/codec.go +++ b/vendor/google.golang.org/grpc/codec.go @@ -27,8 +27,8 @@ import ( // omits the name/string, which vary between the two and are not needed for // anything besides the registry in the encoding package. type baseCodec interface { - Marshal(v interface{}) ([]byte, error) - Unmarshal(data []byte, v interface{}) error + Marshal(v any) ([]byte, error) + Unmarshal(data []byte, v any) error } var _ baseCodec = Codec(nil) @@ -41,9 +41,9 @@ var _ baseCodec = encoding.Codec(nil) // Deprecated: use encoding.Codec instead. type Codec interface { // Marshal returns the wire format of v. - Marshal(v interface{}) ([]byte, error) + Marshal(v any) ([]byte, error) // Unmarshal parses the wire format into v. - Unmarshal(data []byte, v interface{}) error + Unmarshal(data []byte, v any) error // String returns the name of the Codec implementation. This is unused by // gRPC. String() string diff --git a/vendor/google.golang.org/grpc/encoding/encoding.go b/vendor/google.golang.org/grpc/encoding/encoding.go index 195e8448b..db8d3bc51 100644 --- a/vendor/google.golang.org/grpc/encoding/encoding.go +++ b/vendor/google.golang.org/grpc/encoding/encoding.go @@ -77,9 +77,9 @@ func GetCompressor(name string) Compressor { // methods can be called from concurrent goroutines. type Codec interface { // Marshal returns the wire format of v. - Marshal(v interface{}) ([]byte, error) + Marshal(v any) ([]byte, error) // Unmarshal parses the wire format into v. - Unmarshal(data []byte, v interface{}) error + Unmarshal(data []byte, v any) error // Name returns the name of the Codec implementation. The returned string // will be used as part of content type in transmission. The result must be // static; the result cannot change between calls. diff --git a/vendor/google.golang.org/grpc/encoding/proto/proto.go b/vendor/google.golang.org/grpc/encoding/proto/proto.go index 66b97a6f6..929929ae6 100644 --- a/vendor/google.golang.org/grpc/encoding/proto/proto.go +++ b/vendor/google.golang.org/grpc/encoding/proto/proto.go @@ -50,7 +50,7 @@ func capToMaxInt32(val int) uint32 { return uint32(val) } -func marshal(v interface{}, cb *cachedProtoBuffer) ([]byte, error) { +func marshal(v any, cb *cachedProtoBuffer) ([]byte, error) { protoMsg := v.(proto.Message) newSlice := make([]byte, 0, cb.lastMarshaledSize) @@ -64,7 +64,7 @@ func marshal(v interface{}, cb *cachedProtoBuffer) ([]byte, error) { return out, nil } -func (codec) Marshal(v interface{}) ([]byte, error) { +func (codec) Marshal(v any) ([]byte, error) { if pm, ok := v.(proto.Marshaler); ok { // object can marshal itself, no need for buffer return pm.Marshal() @@ -79,7 +79,7 @@ func (codec) Marshal(v interface{}) ([]byte, error) { return out, err } -func (codec) Unmarshal(data []byte, v interface{}) error { +func (codec) Unmarshal(data []byte, v any) error { protoMsg := v.(proto.Message) protoMsg.Reset() @@ -101,7 +101,7 @@ func (codec) Name() string { } var protoBufferPool = &sync.Pool{ - New: func() interface{} { + New: func() any { return &cachedProtoBuffer{ Buffer: proto.Buffer{}, lastMarshaledSize: 16, diff --git a/vendor/google.golang.org/grpc/grpclog/grpclog.go b/vendor/google.golang.org/grpc/grpclog/grpclog.go index 874ea6d98..6d2917e25 100644 --- a/vendor/google.golang.org/grpc/grpclog/grpclog.go +++ b/vendor/google.golang.org/grpc/grpclog/grpclog.go @@ -36,53 +36,53 @@ func V(l int) bool { } // Info logs to the INFO log. -func Info(args ...interface{}) { +func Info(args ...any) { logger.Info(args...) } // Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf. -func Infof(format string, args ...interface{}) { +func Infof(format string, args ...any) { logger.Infof(format, args...) } // Infoln logs to the INFO log. Arguments are handled in the manner of fmt.Println. -func Infoln(args ...interface{}) { +func Infoln(args ...any) { logger.Infoln(args...) } // Warning logs to the WARNING log. -func Warning(args ...interface{}) { +func Warning(args ...any) { logger.Warning(args...) } // Warningf logs to the WARNING log. Arguments are handled in the manner of fmt.Printf. -func Warningf(format string, args ...interface{}) { +func Warningf(format string, args ...any) { logger.Warningf(format, args...) } // Warningln logs to the WARNING log. Arguments are handled in the manner of fmt.Println. -func Warningln(args ...interface{}) { +func Warningln(args ...any) { logger.Warningln(args...) } // Error logs to the ERROR log. -func Error(args ...interface{}) { +func Error(args ...any) { logger.Error(args...) } // Errorf logs to the ERROR log. Arguments are handled in the manner of fmt.Printf. -func Errorf(format string, args ...interface{}) { +func Errorf(format string, args ...any) { logger.Errorf(format, args...) } // Errorln logs to the ERROR log. Arguments are handled in the manner of fmt.Println. -func Errorln(args ...interface{}) { +func Errorln(args ...any) { logger.Errorln(args...) } // Fatal logs to the FATAL log. Arguments are handled in the manner of fmt.Print. // It calls os.Exit() with exit code 1. -func Fatal(args ...interface{}) { +func Fatal(args ...any) { logger.Fatal(args...) // Make sure fatal logs will exit. os.Exit(1) @@ -90,7 +90,7 @@ func Fatal(args ...interface{}) { // Fatalf logs to the FATAL log. Arguments are handled in the manner of fmt.Printf. // It calls os.Exit() with exit code 1. -func Fatalf(format string, args ...interface{}) { +func Fatalf(format string, args ...any) { logger.Fatalf(format, args...) // Make sure fatal logs will exit. os.Exit(1) @@ -98,7 +98,7 @@ func Fatalf(format string, args ...interface{}) { // Fatalln logs to the FATAL log. Arguments are handled in the manner of fmt.Println. // It calle os.Exit()) with exit code 1. -func Fatalln(args ...interface{}) { +func Fatalln(args ...any) { logger.Fatalln(args...) // Make sure fatal logs will exit. os.Exit(1) @@ -107,20 +107,20 @@ func Fatalln(args ...interface{}) { // Print prints to the logger. Arguments are handled in the manner of fmt.Print. // // Deprecated: use Info. -func Print(args ...interface{}) { +func Print(args ...any) { logger.Info(args...) } // Printf prints to the logger. Arguments are handled in the manner of fmt.Printf. // // Deprecated: use Infof. -func Printf(format string, args ...interface{}) { +func Printf(format string, args ...any) { logger.Infof(format, args...) } // Println prints to the logger. Arguments are handled in the manner of fmt.Println. // // Deprecated: use Infoln. -func Println(args ...interface{}) { +func Println(args ...any) { logger.Infoln(args...) } diff --git a/vendor/google.golang.org/grpc/grpclog/logger.go b/vendor/google.golang.org/grpc/grpclog/logger.go index 097494f71..f5ecf0746 100644 --- a/vendor/google.golang.org/grpc/grpclog/logger.go +++ b/vendor/google.golang.org/grpc/grpclog/logger.go @@ -22,12 +22,12 @@ package grpclog // // Deprecated: use LoggerV2. type Logger interface { - Fatal(args ...interface{}) - Fatalf(format string, args ...interface{}) - Fatalln(args ...interface{}) - Print(args ...interface{}) - Printf(format string, args ...interface{}) - Println(args ...interface{}) + Fatal(args ...any) + Fatalf(format string, args ...any) + Fatalln(args ...any) + Print(args ...any) + Printf(format string, args ...any) + Println(args ...any) } // SetLogger sets the logger that is used in grpc. Call only from @@ -43,39 +43,39 @@ type loggerWrapper struct { Logger } -func (g *loggerWrapper) Info(args ...interface{}) { +func (g *loggerWrapper) Info(args ...any) { g.Logger.Print(args...) } -func (g *loggerWrapper) Infoln(args ...interface{}) { +func (g *loggerWrapper) Infoln(args ...any) { g.Logger.Println(args...) } -func (g *loggerWrapper) Infof(format string, args ...interface{}) { +func (g *loggerWrapper) Infof(format string, args ...any) { g.Logger.Printf(format, args...) } -func (g *loggerWrapper) Warning(args ...interface{}) { +func (g *loggerWrapper) Warning(args ...any) { g.Logger.Print(args...) } -func (g *loggerWrapper) Warningln(args ...interface{}) { +func (g *loggerWrapper) Warningln(args ...any) { g.Logger.Println(args...) } -func (g *loggerWrapper) Warningf(format string, args ...interface{}) { +func (g *loggerWrapper) Warningf(format string, args ...any) { g.Logger.Printf(format, args...) } -func (g *loggerWrapper) Error(args ...interface{}) { +func (g *loggerWrapper) Error(args ...any) { g.Logger.Print(args...) } -func (g *loggerWrapper) Errorln(args ...interface{}) { +func (g *loggerWrapper) Errorln(args ...any) { g.Logger.Println(args...) } -func (g *loggerWrapper) Errorf(format string, args ...interface{}) { +func (g *loggerWrapper) Errorf(format string, args ...any) { g.Logger.Printf(format, args...) } diff --git a/vendor/google.golang.org/grpc/grpclog/loggerv2.go b/vendor/google.golang.org/grpc/grpclog/loggerv2.go index d49325776..8b713bda8 100644 --- a/vendor/google.golang.org/grpc/grpclog/loggerv2.go +++ b/vendor/google.golang.org/grpc/grpclog/loggerv2.go @@ -29,35 +29,35 @@ import ( // LoggerV2 does underlying logging work for grpclog. type LoggerV2 interface { // Info logs to INFO log. Arguments are handled in the manner of fmt.Print. - Info(args ...interface{}) + Info(args ...any) // Infoln logs to INFO log. Arguments are handled in the manner of fmt.Println. - Infoln(args ...interface{}) + Infoln(args ...any) // Infof logs to INFO log. Arguments are handled in the manner of fmt.Printf. - Infof(format string, args ...interface{}) + Infof(format string, args ...any) // Warning logs to WARNING log. Arguments are handled in the manner of fmt.Print. - Warning(args ...interface{}) + Warning(args ...any) // Warningln logs to WARNING log. Arguments are handled in the manner of fmt.Println. - Warningln(args ...interface{}) + Warningln(args ...any) // Warningf logs to WARNING log. Arguments are handled in the manner of fmt.Printf. - Warningf(format string, args ...interface{}) + Warningf(format string, args ...any) // Error logs to ERROR log. Arguments are handled in the manner of fmt.Print. - Error(args ...interface{}) + Error(args ...any) // Errorln logs to ERROR log. Arguments are handled in the manner of fmt.Println. - Errorln(args ...interface{}) + Errorln(args ...any) // Errorf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. - Errorf(format string, args ...interface{}) + Errorf(format string, args ...any) // Fatal logs to ERROR log. Arguments are handled in the manner of fmt.Print. // gRPC ensures that all Fatal logs will exit with os.Exit(1). // Implementations may also call os.Exit() with a non-zero exit code. - Fatal(args ...interface{}) + Fatal(args ...any) // Fatalln logs to ERROR log. Arguments are handled in the manner of fmt.Println. // gRPC ensures that all Fatal logs will exit with os.Exit(1). // Implementations may also call os.Exit() with a non-zero exit code. - Fatalln(args ...interface{}) + Fatalln(args ...any) // Fatalf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. // gRPC ensures that all Fatal logs will exit with os.Exit(1). // Implementations may also call os.Exit() with a non-zero exit code. - Fatalf(format string, args ...interface{}) + Fatalf(format string, args ...any) // V reports whether verbosity level l is at least the requested verbose level. V(l int) bool } @@ -139,53 +139,53 @@ func newLoggerV2() LoggerV2 { return NewLoggerV2WithVerbosity(infoW, warningW, errorW, v) } -func (g *loggerT) Info(args ...interface{}) { +func (g *loggerT) Info(args ...any) { g.m[infoLog].Print(args...) } -func (g *loggerT) Infoln(args ...interface{}) { +func (g *loggerT) Infoln(args ...any) { g.m[infoLog].Println(args...) } -func (g *loggerT) Infof(format string, args ...interface{}) { +func (g *loggerT) Infof(format string, args ...any) { g.m[infoLog].Printf(format, args...) } -func (g *loggerT) Warning(args ...interface{}) { +func (g *loggerT) Warning(args ...any) { g.m[warningLog].Print(args...) } -func (g *loggerT) Warningln(args ...interface{}) { +func (g *loggerT) Warningln(args ...any) { g.m[warningLog].Println(args...) } -func (g *loggerT) Warningf(format string, args ...interface{}) { +func (g *loggerT) Warningf(format string, args ...any) { g.m[warningLog].Printf(format, args...) } -func (g *loggerT) Error(args ...interface{}) { +func (g *loggerT) Error(args ...any) { g.m[errorLog].Print(args...) } -func (g *loggerT) Errorln(args ...interface{}) { +func (g *loggerT) Errorln(args ...any) { g.m[errorLog].Println(args...) } -func (g *loggerT) Errorf(format string, args ...interface{}) { +func (g *loggerT) Errorf(format string, args ...any) { g.m[errorLog].Printf(format, args...) } -func (g *loggerT) Fatal(args ...interface{}) { +func (g *loggerT) Fatal(args ...any) { g.m[fatalLog].Fatal(args...) // No need to call os.Exit() again because log.Logger.Fatal() calls os.Exit(). } -func (g *loggerT) Fatalln(args ...interface{}) { +func (g *loggerT) Fatalln(args ...any) { g.m[fatalLog].Fatalln(args...) // No need to call os.Exit() again because log.Logger.Fatal() calls os.Exit(). } -func (g *loggerT) Fatalf(format string, args ...interface{}) { +func (g *loggerT) Fatalf(format string, args ...any) { g.m[fatalLog].Fatalf(format, args...) // No need to call os.Exit() again because log.Logger.Fatal() calls os.Exit(). } diff --git a/vendor/google.golang.org/grpc/health/client.go b/vendor/google.golang.org/grpc/health/client.go index b5bee4838..740745c45 100644 --- a/vendor/google.golang.org/grpc/health/client.go +++ b/vendor/google.golang.org/grpc/health/client.go @@ -56,7 +56,7 @@ const healthCheckMethod = "/grpc.health.v1.Health/Watch" // This function implements the protocol defined at: // https://github.com/grpc/grpc/blob/master/doc/health-checking.md -func clientHealthCheck(ctx context.Context, newStream func(string) (interface{}, error), setConnectivityState func(connectivity.State, error), service string) error { +func clientHealthCheck(ctx context.Context, newStream func(string) (any, error), setConnectivityState func(connectivity.State, error), service string) error { tryCnt := 0 retryConnection: diff --git a/vendor/google.golang.org/grpc/health/grpc_health_v1/health.pb.go b/vendor/google.golang.org/grpc/health/grpc_health_v1/health.pb.go index c99e27ae5..42353621e 100644 --- a/vendor/google.golang.org/grpc/health/grpc_health_v1/health.pb.go +++ b/vendor/google.golang.org/grpc/health/grpc_health_v1/health.pb.go @@ -284,7 +284,7 @@ func RegisterHealthServer(s *grpc.Server, srv HealthServer) { s.RegisterService(&_Health_serviceDesc, srv) } -func _Health_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Health_Check_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(HealthCheckRequest) if err := dec(in); err != nil { return nil, err @@ -296,13 +296,13 @@ func _Health_Check_Handler(srv interface{}, ctx context.Context, dec func(interf Server: srv, FullMethod: "/grpc.health.v1.Health/Check", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(HealthServer).Check(ctx, req.(*HealthCheckRequest)) } return interceptor(ctx, in, info, handler) } -func _Health_Watch_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Health_Watch_Handler(srv any, stream grpc.ServerStream) error { m := new(HealthCheckRequest) if err := stream.RecvMsg(m); err != nil { return err diff --git a/vendor/google.golang.org/grpc/interceptor.go b/vendor/google.golang.org/grpc/interceptor.go index 8b7350022..8365bfc5e 100644 --- a/vendor/google.golang.org/grpc/interceptor.go +++ b/vendor/google.golang.org/grpc/interceptor.go @@ -23,12 +23,12 @@ import ( ) // UnaryInvoker is called by UnaryClientInterceptor to complete RPCs. -type UnaryInvoker func(ctx context.Context, method string, req, reply interface{}, cc *ClientConn, opts ...CallOption) error +type UnaryInvoker func(ctx context.Context, method string, req, reply any, cc *ClientConn, opts ...CallOption) error // UnaryClientInterceptor intercepts the execution of a unary RPC on the client. invoker is the handler to complete the RPC // and it is the responsibility of the interceptor to call it. // This is an EXPERIMENTAL API. -type UnaryClientInterceptor func(ctx context.Context, method string, req, reply interface{}, cc *ClientConn, invoker UnaryInvoker, opts ...CallOption) error +type UnaryClientInterceptor func(ctx context.Context, method string, req, reply any, cc *ClientConn, invoker UnaryInvoker, opts ...CallOption) error // Streamer is called by StreamClientInterceptor to create a ClientStream. type Streamer func(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (ClientStream, error) @@ -42,7 +42,7 @@ type StreamClientInterceptor func(ctx context.Context, desc *StreamDesc, cc *Cli // server side. All per-rpc information may be mutated by the interceptor. type UnaryServerInfo struct { // Server is the service implementation the user provides. This is read-only. - Server interface{} + Server any // FullMethod is the full RPC method string, i.e., /package.service/method. FullMethod string } @@ -51,13 +51,13 @@ type UnaryServerInfo struct { // execution of a unary RPC. If a UnaryHandler returns an error, it should be produced by the // status package, or else gRPC will use codes.Unknown as the status code and err.Error() as // the status message of the RPC. -type UnaryHandler func(ctx context.Context, req interface{}) (interface{}, error) +type UnaryHandler func(ctx context.Context, req any) (any, error) // UnaryServerInterceptor provides a hook to intercept the execution of a unary RPC on the server. info // contains all the information of this RPC the interceptor can operate on. And handler is the wrapper // of the service method implementation. It is the responsibility of the interceptor to invoke handler // to complete the RPC. -type UnaryServerInterceptor func(ctx context.Context, req interface{}, info *UnaryServerInfo, handler UnaryHandler) (resp interface{}, err error) +type UnaryServerInterceptor func(ctx context.Context, req any, info *UnaryServerInfo, handler UnaryHandler) (resp any, err error) // StreamServerInfo consists of various information about a streaming RPC on // server side. All per-rpc information may be mutated by the interceptor. @@ -74,4 +74,4 @@ type StreamServerInfo struct { // info contains all the information of this RPC the interceptor can operate on. And handler is the // service method implementation. It is the responsibility of the interceptor to invoke handler to // complete the RPC. -type StreamServerInterceptor func(srv interface{}, ss ServerStream, info *StreamServerInfo, handler StreamHandler) error +type StreamServerInterceptor func(srv any, ss ServerStream, info *StreamServerInfo, handler StreamHandler) error diff --git a/vendor/google.golang.org/grpc/internal/balancerload/load.go b/vendor/google.golang.org/grpc/internal/balancerload/load.go index 3a905d966..94a08d687 100644 --- a/vendor/google.golang.org/grpc/internal/balancerload/load.go +++ b/vendor/google.golang.org/grpc/internal/balancerload/load.go @@ -25,7 +25,7 @@ import ( // Parser converts loads from metadata into a concrete type. type Parser interface { // Parse parses loads from metadata. - Parse(md metadata.MD) interface{} + Parse(md metadata.MD) any } var parser Parser @@ -38,7 +38,7 @@ func SetParser(lr Parser) { } // Parse calls parser.Read(). -func Parse(md metadata.MD) interface{} { +func Parse(md metadata.MD) any { if parser == nil { return nil } diff --git a/vendor/google.golang.org/grpc/internal/binarylog/method_logger.go b/vendor/google.golang.org/grpc/internal/binarylog/method_logger.go index 160f6e861..9951a4c11 100644 --- a/vendor/google.golang.org/grpc/internal/binarylog/method_logger.go +++ b/vendor/google.golang.org/grpc/internal/binarylog/method_logger.go @@ -208,7 +208,7 @@ type ClientMessage struct { OnClientSide bool // Message can be a proto.Message or []byte. Other messages formats are not // supported. - Message interface{} + Message any } func (c *ClientMessage) toProto() *pb.GrpcLogEntry { @@ -248,7 +248,7 @@ type ServerMessage struct { OnClientSide bool // Message can be a proto.Message or []byte. Other messages formats are not // supported. - Message interface{} + Message any } func (c *ServerMessage) toProto() *pb.GrpcLogEntry { diff --git a/vendor/google.golang.org/grpc/internal/buffer/unbounded.go b/vendor/google.golang.org/grpc/internal/buffer/unbounded.go index 9f6a0c120..f1c23a198 100644 --- a/vendor/google.golang.org/grpc/internal/buffer/unbounded.go +++ b/vendor/google.golang.org/grpc/internal/buffer/unbounded.go @@ -34,18 +34,18 @@ import "sync" // defining a new type specific implementation of this buffer is preferred. See // internal/transport/transport.go for an example of this. type Unbounded struct { - c chan interface{} + c chan any mu sync.Mutex - backlog []interface{} + backlog []any } // NewUnbounded returns a new instance of Unbounded. func NewUnbounded() *Unbounded { - return &Unbounded{c: make(chan interface{}, 1)} + return &Unbounded{c: make(chan any, 1)} } // Put adds t to the unbounded buffer. -func (b *Unbounded) Put(t interface{}) { +func (b *Unbounded) Put(t any) { b.mu.Lock() if len(b.backlog) == 0 { select { @@ -80,6 +80,6 @@ func (b *Unbounded) Load() { // // Upon reading a value from this channel, users are expected to call Load() to // send the next buffered value onto the channel if there is any. -func (b *Unbounded) Get() <-chan interface{} { +func (b *Unbounded) Get() <-chan any { return b.c } diff --git a/vendor/google.golang.org/grpc/internal/channelz/util_linux.go b/vendor/google.golang.org/grpc/internal/channelz/util_linux.go index fdf409d55..54994929d 100644 --- a/vendor/google.golang.org/grpc/internal/channelz/util_linux.go +++ b/vendor/google.golang.org/grpc/internal/channelz/util_linux.go @@ -1,3 +1,4 @@ +//go:build linux && !appengine // +build linux,!appengine /* @@ -25,7 +26,7 @@ import ( ) // GetSocketOption gets the socket option info of the conn. -func GetSocketOption(socket interface{}) *SocketOptionData { +func GetSocketOption(socket any) *SocketOptionData { c, ok := socket.(syscall.Conn) if !ok { return nil diff --git a/vendor/google.golang.org/grpc/internal/channelz/util_nonlinux.go b/vendor/google.golang.org/grpc/internal/channelz/util_nonlinux.go index 8864a0811..3ac5cf628 100644 --- a/vendor/google.golang.org/grpc/internal/channelz/util_nonlinux.go +++ b/vendor/google.golang.org/grpc/internal/channelz/util_nonlinux.go @@ -1,3 +1,4 @@ +//go:build !linux || appengine // +build !linux appengine /* @@ -21,6 +22,6 @@ package channelz // GetSocketOption gets the socket option info of the conn. -func GetSocketOption(c interface{}) *SocketOptionData { +func GetSocketOption(c any) *SocketOptionData { return nil } diff --git a/vendor/google.golang.org/grpc/internal/internal.go b/vendor/google.golang.org/grpc/internal/internal.go index eae18e18c..0d01a1fd8 100644 --- a/vendor/google.golang.org/grpc/internal/internal.go +++ b/vendor/google.golang.org/grpc/internal/internal.go @@ -29,9 +29,9 @@ import ( var ( // WithResolverBuilder is set by dialoptions.go - WithResolverBuilder interface{} // func (resolver.Builder) grpc.DialOption + WithResolverBuilder any // func (resolver.Builder) grpc.DialOption // WithHealthCheckFunc is set by dialoptions.go - WithHealthCheckFunc interface{} // func (HealthChecker) DialOption + WithHealthCheckFunc any // func (HealthChecker) DialOption // HealthCheckFunc is used to provide client-side LB channel health checking HealthCheckFunc HealthChecker // BalancerUnregister is exported by package balancer to unregister a balancer. @@ -43,13 +43,13 @@ var ( // pointer to the wrapped Status proto for a given status.Status without a // call to proto.Clone(). The returned Status proto should not be mutated by // the caller. - StatusRawProto interface{} // func (*status.Status) *spb.Status + StatusRawProto any // func (*status.Status) *spb.Status // NewRequestInfoContext creates a new context based on the argument context attaching // the passed in RequestInfo to the new context. - NewRequestInfoContext interface{} // func(context.Context, credentials.RequestInfo) context.Context + NewRequestInfoContext any // func(context.Context, credentials.RequestInfo) context.Context // ParseServiceConfigForTesting is for creating a fake // ClientConn for resolver testing only - ParseServiceConfigForTesting interface{} // func(string) *serviceconfig.ParseResult + ParseServiceConfigForTesting any // func(string) *serviceconfig.ParseResult ) // HealthChecker defines the signature of the client-side LB channel health checking function. @@ -60,7 +60,7 @@ var ( // // The health checking protocol is defined at: // https://github.com/grpc/grpc/blob/master/doc/health-checking.md -type HealthChecker func(ctx context.Context, newStream func(string) (interface{}, error), setConnectivityState func(connectivity.State, error), serviceName string) error +type HealthChecker func(ctx context.Context, newStream func(string) (any, error), setConnectivityState func(connectivity.State, error), serviceName string) error const ( // CredsBundleModeFallback switches GoogleDefaultCreds to fallback mode. diff --git a/vendor/google.golang.org/grpc/internal/transport/controlbuf.go b/vendor/google.golang.org/grpc/internal/transport/controlbuf.go index ddee20b6b..96083f1cc 100644 --- a/vendor/google.golang.org/grpc/internal/transport/controlbuf.go +++ b/vendor/google.golang.org/grpc/internal/transport/controlbuf.go @@ -34,7 +34,7 @@ var updateHeaderTblSize = func(e *hpack.Encoder, v uint32) { } type itemNode struct { - it interface{} + it any next *itemNode } @@ -43,7 +43,7 @@ type itemList struct { tail *itemNode } -func (il *itemList) enqueue(i interface{}) { +func (il *itemList) enqueue(i any) { n := &itemNode{it: i} if il.tail == nil { il.head, il.tail = n, n @@ -55,11 +55,11 @@ func (il *itemList) enqueue(i interface{}) { // peek returns the first item in the list without removing it from the // list. -func (il *itemList) peek() interface{} { +func (il *itemList) peek() any { return il.head.it } -func (il *itemList) dequeue() interface{} { +func (il *itemList) dequeue() any { if il.head == nil { return nil } @@ -312,7 +312,7 @@ func (c *controlBuffer) put(it cbItem) error { return err } -func (c *controlBuffer) executeAndPut(f func(it interface{}) bool, it cbItem) (bool, error) { +func (c *controlBuffer) executeAndPut(f func(it any) bool, it cbItem) (bool, error) { var wakeUp bool c.mu.Lock() if c.err != nil { @@ -350,7 +350,7 @@ func (c *controlBuffer) executeAndPut(f func(it interface{}) bool, it cbItem) (b } // Note argument f should never be nil. -func (c *controlBuffer) execute(f func(it interface{}) bool, it interface{}) (bool, error) { +func (c *controlBuffer) execute(f func(it any) bool, it any) (bool, error) { c.mu.Lock() if c.err != nil { c.mu.Unlock() @@ -364,7 +364,7 @@ func (c *controlBuffer) execute(f func(it interface{}) bool, it interface{}) (bo return true, nil } -func (c *controlBuffer) get(block bool) (interface{}, error) { +func (c *controlBuffer) get(block bool) (any, error) { for { c.mu.Lock() if c.err != nil { @@ -765,7 +765,7 @@ func (l *loopyWriter) goAwayHandler(g *goAway) error { return nil } -func (l *loopyWriter) handle(i interface{}) error { +func (l *loopyWriter) handle(i any) error { switch i := i.(type) { case *incomingWindowUpdate: return l.incomingWindowUpdateHandler(i) diff --git a/vendor/google.golang.org/grpc/internal/transport/http2_client.go b/vendor/google.golang.org/grpc/internal/transport/http2_client.go index e18935653..ed249afc5 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http2_client.go +++ b/vendor/google.golang.org/grpc/internal/transport/http2_client.go @@ -57,7 +57,7 @@ type http2Client struct { cancel context.CancelFunc ctxDone <-chan struct{} // Cache the ctx.Done() chan. userAgent string - md interface{} + md any conn net.Conn // underlying communication channel loopy *loopyWriter remoteAddr net.Addr @@ -608,7 +608,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Strea } firstTry := true var ch chan struct{} - checkForStreamQuota := func(it interface{}) bool { + checkForStreamQuota := func(it any) bool { if t.streamQuota <= 0 { // Can go negative if server decreases it. if firstTry { t.waitingStreams++ @@ -634,7 +634,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Strea return true } var hdrListSizeErr error - checkForHeaderListSize := func(it interface{}) bool { + checkForHeaderListSize := func(it any) bool { if t.maxSendHeaderListSize == nil { return true } @@ -649,7 +649,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Strea return true } for { - success, err := t.controlBuf.executeAndPut(func(it interface{}) bool { + success, err := t.controlBuf.executeAndPut(func(it any) bool { if !checkForStreamQuota(it) { return false } @@ -750,7 +750,7 @@ func (t *http2Client) closeStream(s *Stream, err error, rst bool, rstCode http2. rst: rst, rstCode: rstCode, } - addBackStreamQuota := func(interface{}) bool { + addBackStreamQuota := func(any) bool { t.streamQuota++ if t.streamQuota > 0 && t.waitingStreams > 0 { select { @@ -899,7 +899,7 @@ func (t *http2Client) updateFlowControl(n uint32) { s.fc.newLimit(n) } t.mu.Unlock() - updateIWS := func(interface{}) bool { + updateIWS := func(any) bool { t.initialWindowSize = int32(n) return true } @@ -1045,7 +1045,7 @@ func (t *http2Client) handleSettings(f *http2.SettingsFrame, isFirst bool) { } updateFuncs = append(updateFuncs, updateStreamQuota) } - t.controlBuf.executeAndPut(func(interface{}) bool { + t.controlBuf.executeAndPut(func(any) bool { for _, f := range updateFuncs { f() } diff --git a/vendor/google.golang.org/grpc/internal/transport/http2_server.go b/vendor/google.golang.org/grpc/internal/transport/http2_server.go index 8b04b0392..dc3cd9a1f 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http2_server.go +++ b/vendor/google.golang.org/grpc/internal/transport/http2_server.go @@ -664,7 +664,7 @@ func (t *http2Server) handleSettings(f *http2.SettingsFrame) { } return nil }) - t.controlBuf.executeAndPut(func(interface{}) bool { + t.controlBuf.executeAndPut(func(any) bool { for _, f := range updateFuncs { f() } @@ -749,7 +749,7 @@ func appendHeaderFieldsFromMD(headerFields []hpack.HeaderField, md metadata.MD) return headerFields } -func (t *http2Server) checkForHeaderListSize(it interface{}) bool { +func (t *http2Server) checkForHeaderListSize(it any) bool { if t.maxSendHeaderListSize == nil { return true } diff --git a/vendor/google.golang.org/grpc/internal/transport/log.go b/vendor/google.golang.org/grpc/internal/transport/log.go index 879df80c4..4ff66f23e 100644 --- a/vendor/google.golang.org/grpc/internal/transport/log.go +++ b/vendor/google.golang.org/grpc/internal/transport/log.go @@ -25,19 +25,19 @@ import "google.golang.org/grpc/grpclog" const logLevel = 2 -func infof(format string, args ...interface{}) { +func infof(format string, args ...any) { if grpclog.V(logLevel) { grpclog.Infof(format, args...) } } -func warningf(format string, args ...interface{}) { +func warningf(format string, args ...any) { if grpclog.V(logLevel) { grpclog.Warningf(format, args...) } } -func errorf(format string, args ...interface{}) { +func errorf(format string, args ...any) { if grpclog.V(logLevel) { grpclog.Errorf(format, args...) } diff --git a/vendor/google.golang.org/grpc/internal/transport/transport.go b/vendor/google.golang.org/grpc/internal/transport/transport.go index a30da9eb3..ac13d9ebb 100644 --- a/vendor/google.golang.org/grpc/internal/transport/transport.go +++ b/vendor/google.golang.org/grpc/internal/transport/transport.go @@ -47,7 +47,7 @@ type bufferPool struct { func newBufferPool() *bufferPool { return &bufferPool{ pool: sync.Pool{ - New: func() interface{} { + New: func() any { return new(bytes.Buffer) }, }, @@ -571,7 +571,7 @@ type ConnectOptions struct { // TargetInfo contains the information of the target such as network address and metadata. type TargetInfo struct { Addr string - Metadata interface{} + Metadata any Authority string } @@ -708,7 +708,7 @@ type ServerTransport interface { } // connectionErrorf creates an ConnectionError with the specified error description. -func connectionErrorf(temp bool, e error, format string, a ...interface{}) ConnectionError { +func connectionErrorf(temp bool, e error, format string, a ...any) ConnectionError { return ConnectionError{ Desc: fmt.Sprintf(format, a...), temp: temp, diff --git a/vendor/google.golang.org/grpc/naming/naming.go b/vendor/google.golang.org/grpc/naming/naming.go index f4c1c8b68..75c7f833a 100644 --- a/vendor/google.golang.org/grpc/naming/naming.go +++ b/vendor/google.golang.org/grpc/naming/naming.go @@ -44,7 +44,7 @@ type Update struct { Addr string // Metadata is the updated metadata. It is nil if there is no metadata update. // Metadata is not required for a custom naming implementation. - Metadata interface{} + Metadata any } // Resolver creates a Watcher for a target to track its resolution changes. diff --git a/vendor/google.golang.org/grpc/preloader.go b/vendor/google.golang.org/grpc/preloader.go index 76acbbcc9..ec890dc4c 100644 --- a/vendor/google.golang.org/grpc/preloader.go +++ b/vendor/google.golang.org/grpc/preloader.go @@ -34,7 +34,7 @@ type PreparedMsg struct { } // Encode marshalls and compresses the message using the codec and compressor for the stream. -func (p *PreparedMsg) Encode(s Stream, msg interface{}) error { +func (p *PreparedMsg) Encode(s Stream, msg any) error { ctx := s.Context() rpcInfo, ok := rpcInfoFromContext(ctx) if !ok { diff --git a/vendor/google.golang.org/grpc/resolver/resolver.go b/vendor/google.golang.org/grpc/resolver/resolver.go index 03567d7be..7b5c37a67 100644 --- a/vendor/google.golang.org/grpc/resolver/resolver.go +++ b/vendor/google.golang.org/grpc/resolver/resolver.go @@ -121,7 +121,7 @@ type Address struct { // to make load balancing decision. // // Deprecated: use Attributes instead. - Metadata interface{} + Metadata any } // BuildOption is a type alias of BuildOptions for legacy reasons. diff --git a/vendor/google.golang.org/grpc/rpc_util.go b/vendor/google.golang.org/grpc/rpc_util.go index edaba7957..b632e2c1c 100644 --- a/vendor/google.golang.org/grpc/rpc_util.go +++ b/vendor/google.golang.org/grpc/rpc_util.go @@ -77,7 +77,7 @@ func NewGZIPCompressorWithLevel(level int) (Compressor, error) { } return &gzipCompressor{ pool: sync.Pool{ - New: func() interface{} { + New: func() any { w, err := gzip.NewWriterLevel(ioutil.Discard, level) if err != nil { panic(err) @@ -497,10 +497,11 @@ type parser struct { // format. The caller owns the returned msg memory. // // If there is an error, possible values are: -// * io.EOF, when no messages remain -// * io.ErrUnexpectedEOF -// * of type transport.ConnectionError -// * an error from the status package +// - io.EOF, when no messages remain +// - io.ErrUnexpectedEOF +// - of type transport.ConnectionError +// - an error from the status package +// // No other error values or types must be returned, which also means // that the underlying io.Reader must not return an incompatible // error. @@ -536,7 +537,7 @@ func (p *parser) recvMsg(maxReceiveMessageSize int) (pf payloadFormat, msg []byt // encode serializes msg and returns a buffer containing the message, or an // error if it is too large to be transmitted by grpc. If msg is nil, it // generates an empty message. -func encode(c baseCodec, msg interface{}) ([]byte, error) { +func encode(c baseCodec, msg any) ([]byte, error) { if msg == nil { // NOTE: typed nils will not be caught by this check return nil, nil } @@ -603,7 +604,7 @@ func msgHeader(data, compData []byte) (hdr []byte, payload []byte) { return hdr, data } -func outPayload(client bool, msg interface{}, data, payload []byte, t time.Time) *stats.OutPayload { +func outPayload(client bool, msg any, data, payload []byte, t time.Time) *stats.OutPayload { return &stats.OutPayload{ Client: client, Payload: msg, @@ -703,7 +704,7 @@ func decompress(compressor encoding.Compressor, d []byte, maxReceiveMessageSize // For the two compressor parameters, both should not be set, but if they are, // dc takes precedence over compressor. // TODO(dfawley): wrap the old compressor/decompressor using the new API? -func recv(p *parser, c baseCodec, s *transport.Stream, dc Decompressor, m interface{}, maxReceiveMessageSize int, payInfo *payloadInfo, compressor encoding.Compressor) error { +func recv(p *parser, c baseCodec, s *transport.Stream, dc Decompressor, m any, maxReceiveMessageSize int, payInfo *payloadInfo, compressor encoding.Compressor) error { d, err := recvAndDecompress(p, s, dc, maxReceiveMessageSize, payInfo, compressor) if err != nil { return err @@ -772,7 +773,7 @@ func ErrorDesc(err error) string { // Errorf returns nil if c is OK. // // Deprecated: use status.Errorf instead. -func Errorf(c codes.Code, format string, a ...interface{}) error { +func Errorf(c codes.Code, format string, a ...any) error { return status.Errorf(c, format, a...) } diff --git a/vendor/google.golang.org/grpc/server.go b/vendor/google.golang.org/grpc/server.go index 0d75cb109..6848b6ddf 100644 --- a/vendor/google.golang.org/grpc/server.go +++ b/vendor/google.golang.org/grpc/server.go @@ -59,7 +59,7 @@ const ( var statusOK = status.New(codes.OK, "") -type methodHandler func(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor UnaryServerInterceptor) (interface{}, error) +type methodHandler func(srv any, ctx context.Context, dec func(any) error, interceptor UnaryServerInterceptor) (any, error) // MethodDesc represents an RPC service's method specification. type MethodDesc struct { @@ -72,19 +72,19 @@ type ServiceDesc struct { ServiceName string // The pointer to the service interface. Used to check whether the user // provided implementation satisfies the interface requirements. - HandlerType interface{} + HandlerType any Methods []MethodDesc Streams []StreamDesc - Metadata interface{} + Metadata any } // service consists of the information of the server serving this service and // the methods in this service. type service struct { - server interface{} // the server for service methods + server any // the server for service methods md map[string]*MethodDesc sd map[string]*StreamDesc - mdata interface{} + mdata any } // Server is a gRPC server to serve RPC requests. @@ -418,7 +418,7 @@ func NewServer(opt ...ServerOption) *Server { // printf records an event in s's event log, unless s has been stopped. // REQUIRES s.mu is held. -func (s *Server) printf(format string, a ...interface{}) { +func (s *Server) printf(format string, a ...any) { if s.events != nil { s.events.Printf(format, a...) } @@ -426,7 +426,7 @@ func (s *Server) printf(format string, a ...interface{}) { // errorf records an error in s's event log, unless s has been stopped. // REQUIRES s.mu is held. -func (s *Server) errorf(format string, a ...interface{}) { +func (s *Server) errorf(format string, a ...any) { if s.events != nil { s.events.Errorf(format, a...) } @@ -435,7 +435,7 @@ func (s *Server) errorf(format string, a ...interface{}) { // RegisterService registers a service and its implementation to the gRPC // server. It is called from the IDL generated code. This must be called before // invoking Serve. -func (s *Server) RegisterService(sd *ServiceDesc, ss interface{}) { +func (s *Server) RegisterService(sd *ServiceDesc, ss any) { ht := reflect.TypeOf(sd.HandlerType).Elem() st := reflect.TypeOf(ss) if !st.Implements(ht) { @@ -444,7 +444,7 @@ func (s *Server) RegisterService(sd *ServiceDesc, ss interface{}) { s.register(sd, ss) } -func (s *Server) register(sd *ServiceDesc, ss interface{}) { +func (s *Server) register(sd *ServiceDesc, ss any) { s.mu.Lock() defer s.mu.Unlock() s.printf("RegisterService(%q)", sd.ServiceName) @@ -485,7 +485,7 @@ type MethodInfo struct { type ServiceInfo struct { Methods []MethodInfo // Metadata is the metadata specified in ServiceDesc when registering service. - Metadata interface{} + Metadata any } // GetServiceInfo returns a map from service names to ServiceInfo. @@ -745,12 +745,12 @@ var _ http.Handler = (*Server)(nil) // To share one port (such as 443 for https) between gRPC and an // existing http.Handler, use a root http.Handler such as: // -// if r.ProtoMajor == 2 && strings.HasPrefix( -// r.Header.Get("Content-Type"), "application/grpc") { -// grpcServer.ServeHTTP(w, r) -// } else { -// yourMux.ServeHTTP(w, r) -// } +// if r.ProtoMajor == 2 && strings.HasPrefix( +// r.Header.Get("Content-Type"), "application/grpc") { +// grpcServer.ServeHTTP(w, r) +// } else { +// yourMux.ServeHTTP(w, r) +// } // // Note that ServeHTTP uses Go's HTTP/2 server implementation which is totally // separate from grpc-go's HTTP/2 server. Performance and features may vary @@ -841,7 +841,7 @@ func (s *Server) incrCallsFailed() { atomic.AddInt64(&s.czData.callsFailed, 1) } -func (s *Server) sendResponse(t transport.ServerTransport, stream *transport.Stream, msg interface{}, cp Compressor, opts *transport.Options, comp encoding.Compressor) error { +func (s *Server) sendResponse(t transport.ServerTransport, stream *transport.Stream, msg any, cp Compressor, opts *transport.Options, comp encoding.Compressor) error { data, err := encode(s.getCodec(stream.ContentSubtype()), msg) if err != nil { grpclog.Errorln("grpc: server failed to encode response: ", err) @@ -894,7 +894,7 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport. defer func() { if trInfo != nil { if err != nil && err != io.EOF { - trInfo.tr.LazyLog(&fmtStringer{"%v", []interface{}{err}}, true) + trInfo.tr.LazyLog(&fmtStringer{"%v", []any{err}}, true) trInfo.tr.SetError() } trInfo.tr.Finish() @@ -997,7 +997,7 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport. if channelz.IsOn() { t.IncrMsgRecv() } - df := func(v interface{}) error { + df := func(v any) error { if err := s.getCodec(stream.ContentSubtype()).Unmarshal(d, v); err != nil { return status.Errorf(codes.Internal, "grpc: error unmarshalling request: %v", err) } @@ -1145,7 +1145,7 @@ func (s *Server) processStreamingRPC(t transport.ServerTransport, stream *transp if trInfo != nil { ss.mu.Lock() if err != nil && err != io.EOF { - ss.trInfo.tr.LazyLog(&fmtStringer{"%v", []interface{}{err}}, true) + ss.trInfo.tr.LazyLog(&fmtStringer{"%v", []any{err}}, true) ss.trInfo.tr.SetError() } ss.trInfo.tr.Finish() @@ -1229,7 +1229,7 @@ func (s *Server) processStreamingRPC(t transport.ServerTransport, stream *transp trInfo.tr.LazyLog(&trInfo.firstLine, false) } var appErr error - var server interface{} + var server any if srv != nil { server = srv.server } @@ -1288,13 +1288,13 @@ func (s *Server) handleStream(t transport.ServerTransport, stream *transport.Str pos := strings.LastIndex(sm, "/") if pos == -1 { if trInfo != nil { - trInfo.tr.LazyLog(&fmtStringer{"Malformed method name %q", []interface{}{sm}}, true) + trInfo.tr.LazyLog(&fmtStringer{"Malformed method name %q", []any{sm}}, true) trInfo.tr.SetError() } errDesc := fmt.Sprintf("malformed method name: %q", stream.Method()) if err := t.WriteStatus(stream, status.New(codes.ResourceExhausted, errDesc)); err != nil { if trInfo != nil { - trInfo.tr.LazyLog(&fmtStringer{"%v", []interface{}{err}}, true) + trInfo.tr.LazyLog(&fmtStringer{"%v", []any{err}}, true) trInfo.tr.SetError() } grpclog.Warningf("grpc: Server.handleStream failed to write status: %v", err) @@ -1335,7 +1335,7 @@ func (s *Server) handleStream(t transport.ServerTransport, stream *transport.Str } if err := t.WriteStatus(stream, status.New(codes.Unimplemented, errDesc)); err != nil { if trInfo != nil { - trInfo.tr.LazyLog(&fmtStringer{"%v", []interface{}{err}}, true) + trInfo.tr.LazyLog(&fmtStringer{"%v", []any{err}}, true) trInfo.tr.SetError() } grpclog.Warningf("grpc: Server.handleStream failed to write status: %v", err) @@ -1489,9 +1489,9 @@ func (s *Server) getCodec(contentSubtype string) baseCodec { // SetHeader sets the header metadata. // When called multiple times, all the provided metadata will be merged. // All the metadata will be sent out when one of the following happens: -// - grpc.SendHeader() is called; -// - The first response is sent out; -// - An RPC status is sent out (error or success). +// - grpc.SendHeader() is called; +// - The first response is sent out; +// - An RPC status is sent out (error or success). func SetHeader(ctx context.Context, md metadata.MD) error { if md.Len() == 0 { return nil diff --git a/vendor/google.golang.org/grpc/stats/stats.go b/vendor/google.golang.org/grpc/stats/stats.go index 9e22c393f..643de8208 100644 --- a/vendor/google.golang.org/grpc/stats/stats.go +++ b/vendor/google.golang.org/grpc/stats/stats.go @@ -59,7 +59,7 @@ type InPayload struct { // Client is true if this InPayload is from client side. Client bool // Payload is the payload with original type. - Payload interface{} + Payload any // Data is the serialized message payload. Data []byte // Length is the length of uncompressed data. @@ -121,7 +121,7 @@ type OutPayload struct { // Client is true if this OutPayload is from client side. Client bool // Payload is the payload with original type. - Payload interface{} + Payload any // Data is the serialized message payload. Data []byte // Length is the length of uncompressed data. diff --git a/vendor/google.golang.org/grpc/status/status.go b/vendor/google.golang.org/grpc/status/status.go index a1348e9b1..86424dc6e 100644 --- a/vendor/google.golang.org/grpc/status/status.go +++ b/vendor/google.golang.org/grpc/status/status.go @@ -114,7 +114,7 @@ func New(c codes.Code, msg string) *Status { } // Newf returns New(c, fmt.Sprintf(format, a...)). -func Newf(c codes.Code, format string, a ...interface{}) *Status { +func Newf(c codes.Code, format string, a ...any) *Status { return New(c, fmt.Sprintf(format, a...)) } @@ -124,7 +124,7 @@ func Error(c codes.Code, msg string) error { } // Errorf returns Error(c, fmt.Sprintf(format, a...)). -func Errorf(c codes.Code, format string, a ...interface{}) error { +func Errorf(c codes.Code, format string, a ...any) error { return Error(c, fmt.Sprintf(format, a...)) } @@ -180,11 +180,11 @@ func (s *Status) WithDetails(details ...proto.Message) (*Status, error) { // Details returns a slice of details messages attached to the status. // If a detail cannot be decoded, the error is returned in place of the detail. -func (s *Status) Details() []interface{} { +func (s *Status) Details() []any { if s == nil || s.s == nil { return nil } - details := make([]interface{}, 0, len(s.s.Details)) + details := make([]any, 0, len(s.s.Details)) for _, any := range s.s.Details { detail := &ptypes.DynamicAny{} if err := ptypes.UnmarshalAny(any, detail); err != nil { diff --git a/vendor/google.golang.org/grpc/stream.go b/vendor/google.golang.org/grpc/stream.go index bb99940e3..e4237a940 100644 --- a/vendor/google.golang.org/grpc/stream.go +++ b/vendor/google.golang.org/grpc/stream.go @@ -48,7 +48,7 @@ import ( // should be produced by the status package, or else gRPC will use // codes.Unknown as the status code and err.Error() as the status message // of the RPC. -type StreamHandler func(srv interface{}, stream ServerStream) error +type StreamHandler func(srv any, stream ServerStream) error // StreamDesc represents a streaming RPC service's method specification. type StreamDesc struct { @@ -67,9 +67,9 @@ type Stream interface { // Deprecated: See ClientStream and ServerStream documentation instead. Context() context.Context // Deprecated: See ClientStream and ServerStream documentation instead. - SendMsg(m interface{}) error + SendMsg(m any) error // Deprecated: See ClientStream and ServerStream documentation instead. - RecvMsg(m interface{}) error + RecvMsg(m any) error } // ClientStream defines the client-side behavior of a streaming RPC. @@ -111,7 +111,7 @@ type ClientStream interface { // calling RecvMsg on the same stream at the same time, but it is not safe // to call SendMsg on the same stream in different goroutines. It is also // not safe to call CloseSend concurrently with SendMsg. - SendMsg(m interface{}) error + SendMsg(m any) error // RecvMsg blocks until it receives a message into m or the stream is // done. It returns io.EOF when the stream completes successfully. On // any other error, the stream is aborted and the error contains the RPC @@ -120,7 +120,7 @@ type ClientStream interface { // It is safe to have a goroutine calling SendMsg and another goroutine // calling RecvMsg on the same stream at the same time, but it is not // safe to call RecvMsg on the same stream in different goroutines. - RecvMsg(m interface{}) error + RecvMsg(m any) error } // NewStream creates a new Stream for the client side. This is typically @@ -129,13 +129,13 @@ type ClientStream interface { // To ensure resources are not leaked due to the stream returned, one of the following // actions must be performed: // -// 1. Call Close on the ClientConn. -// 2. Cancel the context provided. -// 3. Call RecvMsg until a non-nil error is returned. A protobuf-generated -// client-streaming RPC, for instance, might use the helper function -// CloseAndRecv (note that CloseSend does not Recv, therefore is not -// guaranteed to release all resources). -// 4. Receive a non-nil, non-io.EOF error from Header or SendMsg. +// 1. Call Close on the ClientConn. +// 2. Cancel the context provided. +// 3. Call RecvMsg until a non-nil error is returned. A protobuf-generated +// client-streaming RPC, for instance, might use the helper function +// CloseAndRecv (note that CloseSend does not Recv, therefore is not +// guaranteed to release all resources). +// 4. Receive a non-nil, non-io.EOF error from Header or SendMsg. // // If none of the above happen, a goroutine and a context will be leaked, and grpc // will not call the optionally-configured stats handler with a stats.End message. @@ -677,7 +677,7 @@ func (cs *clientStream) bufferForRetryLocked(sz int, op func(a *csAttempt) error cs.buffer = append(cs.buffer, op) } -func (cs *clientStream) SendMsg(m interface{}) (err error) { +func (cs *clientStream) SendMsg(m any) (err error) { defer func() { if err != nil && err != io.EOF { // Call finish on the client stream for errors generated by this SendMsg @@ -723,7 +723,7 @@ func (cs *clientStream) SendMsg(m interface{}) (err error) { return } -func (cs *clientStream) RecvMsg(m interface{}) error { +func (cs *clientStream) RecvMsg(m any) error { if cs.binlog != nil && !cs.serverHeaderBinlogged { // Call Header() to binary log header if it's not already logged. cs.Header() @@ -833,7 +833,7 @@ func (cs *clientStream) finish(err error) { cs.cancel() } -func (a *csAttempt) sendMsg(m interface{}, hdr, payld, data []byte) error { +func (a *csAttempt) sendMsg(m any, hdr, payld, data []byte) error { cs := a.cs if a.trInfo != nil { a.mu.Lock() @@ -860,7 +860,7 @@ func (a *csAttempt) sendMsg(m interface{}, hdr, payld, data []byte) error { return nil } -func (a *csAttempt) recvMsg(m interface{}, payInfo *payloadInfo) (err error) { +func (a *csAttempt) recvMsg(m any, payInfo *payloadInfo) (err error) { cs := a.cs if a.statsHandler != nil && payInfo == nil { payInfo = &payloadInfo{} @@ -1147,7 +1147,7 @@ func (as *addrConnStream) Context() context.Context { return as.s.Context() } -func (as *addrConnStream) SendMsg(m interface{}) (err error) { +func (as *addrConnStream) SendMsg(m any) (err error) { defer func() { if err != nil && err != io.EOF { // Call finish on the client stream for errors generated by this SendMsg @@ -1192,7 +1192,7 @@ func (as *addrConnStream) SendMsg(m interface{}) (err error) { return nil } -func (as *addrConnStream) RecvMsg(m interface{}) (err error) { +func (as *addrConnStream) RecvMsg(m any) (err error) { defer func() { if err != nil || !as.desc.ServerStreams { // err != nil or non-server-streaming indicates end of stream. @@ -1306,7 +1306,7 @@ type ServerStream interface { // It is safe to have a goroutine calling SendMsg and another goroutine // calling RecvMsg on the same stream at the same time, but it is not safe // to call SendMsg on the same stream in different goroutines. - SendMsg(m interface{}) error + SendMsg(m any) error // RecvMsg blocks until it receives a message into m or the stream is // done. It returns io.EOF when the client has performed a CloseSend. On // any non-EOF error, the stream is aborted and the error contains the @@ -1315,7 +1315,7 @@ type ServerStream interface { // It is safe to have a goroutine calling SendMsg and another goroutine // calling RecvMsg on the same stream at the same time, but it is not // safe to call RecvMsg on the same stream in different goroutines. - RecvMsg(m interface{}) error + RecvMsg(m any) error } // serverStream implements a server side Stream. @@ -1379,7 +1379,7 @@ func (ss *serverStream) SetTrailer(md metadata.MD) { ss.s.SetTrailer(md) } -func (ss *serverStream) SendMsg(m interface{}) (err error) { +func (ss *serverStream) SendMsg(m any) (err error) { defer func() { if ss.trInfo != nil { ss.mu.Lock() @@ -1387,7 +1387,7 @@ func (ss *serverStream) SendMsg(m interface{}) (err error) { if err == nil { ss.trInfo.tr.LazyLog(&payload{sent: true, msg: m}, true) } else { - ss.trInfo.tr.LazyLog(&fmtStringer{"%v", []interface{}{err}}, true) + ss.trInfo.tr.LazyLog(&fmtStringer{"%v", []any{err}}, true) ss.trInfo.tr.SetError() } } @@ -1439,7 +1439,7 @@ func (ss *serverStream) SendMsg(m interface{}) (err error) { return nil } -func (ss *serverStream) RecvMsg(m interface{}) (err error) { +func (ss *serverStream) RecvMsg(m any) (err error) { defer func() { if ss.trInfo != nil { ss.mu.Lock() @@ -1447,7 +1447,7 @@ func (ss *serverStream) RecvMsg(m interface{}) (err error) { if err == nil { ss.trInfo.tr.LazyLog(&payload{sent: false, msg: m}, true) } else if err != io.EOF { - ss.trInfo.tr.LazyLog(&fmtStringer{"%v", []interface{}{err}}, true) + ss.trInfo.tr.LazyLog(&fmtStringer{"%v", []any{err}}, true) ss.trInfo.tr.SetError() } } @@ -1510,7 +1510,7 @@ func MethodFromServerStream(stream ServerStream) (string, bool) { // prepareMsg returns the hdr, payload and data // using the compressors passed or using the // passed preparedmsg -func prepareMsg(m interface{}, codec baseCodec, cp Compressor, comp encoding.Compressor) (hdr, payload, data []byte, err error) { +func prepareMsg(m any, codec baseCodec, cp Compressor, comp encoding.Compressor) (hdr, payload, data []byte, err error) { if preparedMsg, ok := m.(*PreparedMsg); ok { return preparedMsg.hdr, preparedMsg.payload, preparedMsg.encodedData, nil } diff --git a/vendor/google.golang.org/grpc/trace.go b/vendor/google.golang.org/grpc/trace.go index 0a57b9994..f7a94ebc9 100644 --- a/vendor/google.golang.org/grpc/trace.go +++ b/vendor/google.golang.org/grpc/trace.go @@ -100,8 +100,8 @@ func truncate(x string, l int) string { // payload represents an RPC request or response payload. type payload struct { - sent bool // whether this is an outgoing payload - msg interface{} // e.g. a proto.Message + sent bool // whether this is an outgoing payload + msg any // e.g. a proto.Message // TODO(dsymonds): add stringifying info to codec, and limit how much we hold here? } @@ -114,7 +114,7 @@ func (p payload) String() string { type fmtStringer struct { format string - a []interface{} + a []any } func (f *fmtStringer) String() string { diff --git a/vendor/gopkg.in/yaml.v2/decode.go b/vendor/gopkg.in/yaml.v2/decode.go index e4e56e28e..082753d67 100644 --- a/vendor/gopkg.in/yaml.v2/decode.go +++ b/vendor/gopkg.in/yaml.v2/decode.go @@ -234,7 +234,7 @@ type decoder struct { var ( mapItemType = reflect.TypeOf(MapItem{}) durationType = reflect.TypeOf(time.Duration(0)) - defaultMapType = reflect.TypeOf(map[interface{}]interface{}{}) + defaultMapType = reflect.TypeOf(map[any]any{}) ifaceType = defaultMapType.Elem() timeType = reflect.TypeOf(time.Time{}) ptrTimeType = reflect.TypeOf(&time.Time{}) @@ -263,7 +263,7 @@ func (d *decoder) terror(n *node, tag string, out reflect.Value) { func (d *decoder) callUnmarshaler(n *node, u Unmarshaler) (good bool) { terrlen := len(d.terrors) - err := u.UnmarshalYAML(func(v interface{}) (err error) { + err := u.UnmarshalYAML(func(v any) (err error) { defer handleErr(&err) d.unmarshal(n, reflect.ValueOf(v)) if len(d.terrors) > terrlen { @@ -368,7 +368,7 @@ func resetMap(out reflect.Value) { func (d *decoder) scalar(n *node, out reflect.Value) bool { var tag string - var resolved interface{} + var resolved any if n.tag == "" && !n.implicit { tag = yaml_STR_TAG resolved = n.value @@ -533,7 +533,7 @@ func (d *decoder) scalar(n *node, out reflect.Value) bool { return false } -func settableValueOf(i interface{}) reflect.Value { +func settableValueOf(i any) reflect.Value { v := reflect.ValueOf(i) sv := reflect.New(v.Type()).Elem() sv.Set(v) @@ -554,7 +554,7 @@ func (d *decoder) sequence(n *node, out reflect.Value) (good bool) { case reflect.Interface: // No type hints. Will have to use a generic sequence. iface = out - out = settableValueOf(make([]interface{}, l)) + out = settableValueOf(make([]any, l)) default: d.terror(n, yaml_SEQ_TAG, out) return false diff --git a/vendor/gopkg.in/yaml.v2/resolve.go b/vendor/gopkg.in/yaml.v2/resolve.go index 6c151db6f..5f1ee20f0 100644 --- a/vendor/gopkg.in/yaml.v2/resolve.go +++ b/vendor/gopkg.in/yaml.v2/resolve.go @@ -10,7 +10,7 @@ import ( ) type resolveMapItem struct { - value interface{} + value any tag string } @@ -30,7 +30,7 @@ func init() { t[int('.')] = '.' // Float (potentially in map) var resolveMapList = []struct { - v interface{} + v any tag string l []string }{ @@ -83,7 +83,7 @@ func resolvableTag(tag string) bool { var yamlStyleFloat = regexp.MustCompile(`^[-+]?[0-9]*\.?[0-9]+([eE][-+][0-9]+)?$`) -func resolve(tag string, in string) (rtag string, out interface{}) { +func resolve(tag string, in string) (rtag string, out any) { if !resolvableTag(tag) { return tag, in } @@ -180,7 +180,7 @@ func resolve(tag string, in string) (rtag string, out interface{}) { return yaml_INT_TAG, uintv } } else if strings.HasPrefix(plain, "-0b") { - intv, err := strconv.ParseInt("-" + plain[3:], 2, 64) + intv, err := strconv.ParseInt("-"+plain[3:], 2, 64) if err == nil { if true || intv == int64(int(intv)) { return yaml_INT_TAG, int(intv) diff --git a/vendor/gopkg.in/yaml.v2/scannerc.go b/vendor/gopkg.in/yaml.v2/scannerc.go index 077fd1dd2..6881d03f4 100644 --- a/vendor/gopkg.in/yaml.v2/scannerc.go +++ b/vendor/gopkg.in/yaml.v2/scannerc.go @@ -614,10 +614,10 @@ func yaml_parser_set_scanner_tag_error(parser *yaml_parser_t, directive bool, co return yaml_parser_set_scanner_error(parser, context, context_mark, problem) } -func trace(args ...interface{}) func() { - pargs := append([]interface{}{"+++"}, args...) +func trace(args ...any) func() { + pargs := append([]any{"+++"}, args...) fmt.Println(pargs...) - pargs = append([]interface{}{"---"}, args...) + pargs = append([]any{"---"}, args...) return func() { fmt.Println(pargs...) } } @@ -1485,11 +1485,11 @@ func yaml_parser_scan_to_next_token(parser *yaml_parser_t) bool { // Scan a YAML-DIRECTIVE or TAG-DIRECTIVE token. // // Scope: -// %YAML 1.1 # a comment \n -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -// %TAG !yaml! tag:yaml.org,2002: \n -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // +// %YAML 1.1 # a comment \n +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +// %TAG !yaml! tag:yaml.org,2002: \n +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ func yaml_parser_scan_directive(parser *yaml_parser_t, token *yaml_token_t) bool { // Eat '%'. start_mark := parser.mark @@ -1586,11 +1586,11 @@ func yaml_parser_scan_directive(parser *yaml_parser_t, token *yaml_token_t) bool // Scan the directive name. // // Scope: -// %YAML 1.1 # a comment \n -// ^^^^ -// %TAG !yaml! tag:yaml.org,2002: \n -// ^^^ // +// %YAML 1.1 # a comment \n +// ^^^^ +// %TAG !yaml! tag:yaml.org,2002: \n +// ^^^ func yaml_parser_scan_directive_name(parser *yaml_parser_t, start_mark yaml_mark_t, name *[]byte) bool { // Consume the directive name. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { @@ -1625,8 +1625,9 @@ func yaml_parser_scan_directive_name(parser *yaml_parser_t, start_mark yaml_mark // Scan the value of VERSION-DIRECTIVE. // // Scope: -// %YAML 1.1 # a comment \n -// ^^^^^^ +// +// %YAML 1.1 # a comment \n +// ^^^^^^ func yaml_parser_scan_version_directive_value(parser *yaml_parser_t, start_mark yaml_mark_t, major, minor *int8) bool { // Eat whitespaces. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { @@ -1664,10 +1665,11 @@ const max_number_length = 2 // Scan the version number of VERSION-DIRECTIVE. // // Scope: -// %YAML 1.1 # a comment \n -// ^ -// %YAML 1.1 # a comment \n -// ^ +// +// %YAML 1.1 # a comment \n +// ^ +// %YAML 1.1 # a comment \n +// ^ func yaml_parser_scan_version_directive_number(parser *yaml_parser_t, start_mark yaml_mark_t, number *int8) bool { // Repeat while the next character is digit. @@ -1701,9 +1703,9 @@ func yaml_parser_scan_version_directive_number(parser *yaml_parser_t, start_mark // Scan the value of a TAG-DIRECTIVE token. // // Scope: -// %TAG !yaml! tag:yaml.org,2002: \n -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // +// %TAG !yaml! tag:yaml.org,2002: \n +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ func yaml_parser_scan_tag_directive_value(parser *yaml_parser_t, start_mark yaml_mark_t, handle, prefix *[]byte) bool { var handle_value, prefix_value []byte diff --git a/vendor/gopkg.in/yaml.v2/yaml.go b/vendor/gopkg.in/yaml.v2/yaml.go index de85aa4cd..911630909 100644 --- a/vendor/gopkg.in/yaml.v2/yaml.go +++ b/vendor/gopkg.in/yaml.v2/yaml.go @@ -2,8 +2,7 @@ // // Source code and other details for the project are available at GitHub: // -// https://github.com/go-yaml/yaml -// +// https://github.com/go-yaml/yaml package yaml import ( @@ -21,7 +20,7 @@ type MapSlice []MapItem // MapItem is an item in a MapSlice. type MapItem struct { - Key, Value interface{} + Key, Value any } // The Unmarshaler interface may be implemented by types to customize their @@ -30,7 +29,7 @@ type MapItem struct { // YAML value into a field or variable. It is safe to call the unmarshal // function parameter more than once if necessary. type Unmarshaler interface { - UnmarshalYAML(unmarshal func(interface{}) error) error + UnmarshalYAML(unmarshal func(any) error) error } // The Marshaler interface may be implemented by types to customize their @@ -40,7 +39,7 @@ type Unmarshaler interface { // If an error is returned by MarshalYAML, the marshaling procedure stops // and returns with the provided error. type Marshaler interface { - MarshalYAML() (interface{}, error) + MarshalYAML() (any, error) } // Unmarshal decodes the first document found within the in byte slice @@ -67,17 +66,16 @@ type Marshaler interface { // // For example: // -// type T struct { -// F int `yaml:"a,omitempty"` -// B int -// } -// var t T -// yaml.Unmarshal([]byte("a: 1\nb: 2"), &t) +// type T struct { +// F int `yaml:"a,omitempty"` +// B int +// } +// var t T +// yaml.Unmarshal([]byte("a: 1\nb: 2"), &t) // // See the documentation of Marshal for the format of tags and a list of // supported tag options. -// -func Unmarshal(in []byte, out interface{}) (err error) { +func Unmarshal(in []byte, out any) (err error) { return unmarshal(in, out, false) } @@ -85,7 +83,7 @@ func Unmarshal(in []byte, out interface{}) (err error) { // in the data that do not have corresponding struct members, or mapping // keys that are duplicates, will result in // an error. -func UnmarshalStrict(in []byte, out interface{}) (err error) { +func UnmarshalStrict(in []byte, out any) (err error) { return unmarshal(in, out, true) } @@ -116,7 +114,7 @@ func (dec *Decoder) SetStrict(strict bool) { // // See the documentation for Unmarshal for details about the // conversion of YAML into a Go value. -func (dec *Decoder) Decode(v interface{}) (err error) { +func (dec *Decoder) Decode(v any) (err error) { d := newDecoder(dec.strict) defer handleErr(&err) node := dec.parser.parse() @@ -134,7 +132,7 @@ func (dec *Decoder) Decode(v interface{}) (err error) { return nil } -func unmarshal(in []byte, out interface{}, strict bool) (err error) { +func unmarshal(in []byte, out any, strict bool) (err error) { defer handleErr(&err) d := newDecoder(strict) p := newParser(in) @@ -166,37 +164,36 @@ func unmarshal(in []byte, out interface{}, strict bool) (err error) { // // The field tag format accepted is: // -// `(...) yaml:"[][,[,]]" (...)` +// `(...) yaml:"[][,[,]]" (...)` // // The following flags are currently supported: // -// omitempty Only include the field if it's not set to the zero -// value for the type or to empty slices or maps. -// Zero valued structs will be omitted if all their public -// fields are zero, unless they implement an IsZero -// method (see the IsZeroer interface type), in which -// case the field will be included if that method returns true. +// omitempty Only include the field if it's not set to the zero +// value for the type or to empty slices or maps. +// Zero valued structs will be omitted if all their public +// fields are zero, unless they implement an IsZero +// method (see the IsZeroer interface type), in which +// case the field will be included if that method returns true. // -// flow Marshal using a flow style (useful for structs, -// sequences and maps). +// flow Marshal using a flow style (useful for structs, +// sequences and maps). // -// inline Inline the field, which must be a struct or a map, -// causing all of its fields or keys to be processed as if -// they were part of the outer struct. For maps, keys must -// not conflict with the yaml keys of other struct fields. +// inline Inline the field, which must be a struct or a map, +// causing all of its fields or keys to be processed as if +// they were part of the outer struct. For maps, keys must +// not conflict with the yaml keys of other struct fields. // // In addition, if the key is "-", the field is ignored. // // For example: // -// type T struct { -// F int `yaml:"a,omitempty"` -// B int -// } -// yaml.Marshal(&T{B: 2}) // Returns "b: 2\n" -// yaml.Marshal(&T{F: 1}} // Returns "a: 1\nb: 0\n" -// -func Marshal(in interface{}) (out []byte, err error) { +// type T struct { +// F int `yaml:"a,omitempty"` +// B int +// } +// yaml.Marshal(&T{B: 2}) // Returns "b: 2\n" +// yaml.Marshal(&T{F: 1}} // Returns "a: 1\nb: 0\n" +func Marshal(in any) (out []byte, err error) { defer handleErr(&err) e := newEncoder() defer e.destroy() @@ -227,7 +224,7 @@ func NewEncoder(w io.Writer) *Encoder { // // See the documentation for Marshal for details about the conversion of Go // values to YAML. -func (e *Encoder) Encode(v interface{}) (err error) { +func (e *Encoder) Encode(v any) (err error) { defer handleErr(&err) e.encoder.marshalDoc("", reflect.ValueOf(v)) return nil @@ -259,7 +256,7 @@ func fail(err error) { panic(yamlError{err}) } -func failf(format string, args ...interface{}) { +func failf(format string, args ...any) { panic(yamlError{fmt.Errorf("yaml: "+format, args...)}) } diff --git a/vendor/sigs.k8s.io/yaml/yaml.go b/vendor/sigs.k8s.io/yaml/yaml.go index 024596112..34168e55f 100644 --- a/vendor/sigs.k8s.io/yaml/yaml.go +++ b/vendor/sigs.k8s.io/yaml/yaml.go @@ -13,7 +13,7 @@ import ( // Marshal marshals the object into JSON then converts JSON to YAML and returns the // YAML. -func Marshal(o interface{}) ([]byte, error) { +func Marshal(o any) ([]byte, error) { j, err := json.Marshal(o) if err != nil { return nil, fmt.Errorf("error marshaling into JSON: %v", err) @@ -32,19 +32,19 @@ type JSONOpt func(*json.Decoder) *json.Decoder // Unmarshal converts YAML to JSON then uses JSON to unmarshal into an object, // optionally configuring the behavior of the JSON unmarshal. -func Unmarshal(y []byte, o interface{}, opts ...JSONOpt) error { +func Unmarshal(y []byte, o any, opts ...JSONOpt) error { return yamlUnmarshal(y, o, false, opts...) } // UnmarshalStrict strictly converts YAML to JSON then uses JSON to unmarshal // into an object, optionally configuring the behavior of the JSON unmarshal. -func UnmarshalStrict(y []byte, o interface{}, opts ...JSONOpt) error { +func UnmarshalStrict(y []byte, o any, opts ...JSONOpt) error { return yamlUnmarshal(y, o, true, append(opts, DisallowUnknownFields)...) } // yamlUnmarshal unmarshals the given YAML byte stream into the given interface, // optionally performing the unmarshalling strictly -func yamlUnmarshal(y []byte, o interface{}, strict bool, opts ...JSONOpt) error { +func yamlUnmarshal(y []byte, o any, strict bool, opts ...JSONOpt) error { vo := reflect.ValueOf(o) unmarshalFn := yaml.Unmarshal if strict { @@ -67,7 +67,7 @@ func yamlUnmarshal(y []byte, o interface{}, strict bool, opts ...JSONOpt) error // object, optionally applying decoder options prior to decoding. We are not // using json.Unmarshal directly as we want the chance to pass in non-default // options. -func jsonUnmarshal(r io.Reader, o interface{}, opts ...JSONOpt) error { +func jsonUnmarshal(r io.Reader, o any, opts ...JSONOpt) error { d := json.NewDecoder(r) for _, opt := range opts { d = opt(d) @@ -81,7 +81,7 @@ func jsonUnmarshal(r io.Reader, o interface{}, opts ...JSONOpt) error { // JSONToYAML Converts JSON to YAML. func JSONToYAML(j []byte) ([]byte, error) { // Convert the JSON to an object. - var jsonObj interface{} + var jsonObj any // We are using yaml.Unmarshal here (instead of json.Unmarshal) because the // Go JSON library doesn't try to pick the right number type (int, float, // etc.) when unmarshalling to interface{}, it just picks float64 @@ -100,12 +100,12 @@ func JSONToYAML(j []byte) ([]byte, error) { // passing JSON through this method should be a no-op. // // Things YAML can do that are not supported by JSON: -// * In YAML you can have binary and null keys in your maps. These are invalid -// in JSON. (int and float keys are converted to strings.) -// * Binary data in YAML with the !!binary tag is not supported. If you want to -// use binary data with this library, encode the data as base64 as usual but do -// not use the !!binary tag in your YAML. This will ensure the original base64 -// encoded data makes it all the way through to the JSON. +// - In YAML you can have binary and null keys in your maps. These are invalid +// in JSON. (int and float keys are converted to strings.) +// - Binary data in YAML with the !!binary tag is not supported. If you want to +// use binary data with this library, encode the data as base64 as usual but do +// not use the !!binary tag in your YAML. This will ensure the original base64 +// encoded data makes it all the way through to the JSON. // // For strict decoding of YAML, use YAMLToJSONStrict. func YAMLToJSON(y []byte) ([]byte, error) { @@ -118,9 +118,9 @@ func YAMLToJSONStrict(y []byte) ([]byte, error) { return yamlToJSON(y, nil, yaml.UnmarshalStrict) } -func yamlToJSON(y []byte, jsonTarget *reflect.Value, yamlUnmarshal func([]byte, interface{}) error) ([]byte, error) { +func yamlToJSON(y []byte, jsonTarget *reflect.Value, yamlUnmarshal func([]byte, any) error) ([]byte, error) { // Convert the YAML to an object. - var yamlObj interface{} + var yamlObj any err := yamlUnmarshal(y, &yamlObj) if err != nil { return nil, err @@ -139,7 +139,7 @@ func yamlToJSON(y []byte, jsonTarget *reflect.Value, yamlUnmarshal func([]byte, return json.Marshal(jsonObj) } -func convertToJSONableObject(yamlObj interface{}, jsonTarget *reflect.Value) (interface{}, error) { +func convertToJSONableObject(yamlObj any, jsonTarget *reflect.Value) (any, error) { var err error // Resolve jsonTarget to a concrete value (i.e. not a pointer or an @@ -163,14 +163,14 @@ func convertToJSONableObject(yamlObj interface{}, jsonTarget *reflect.Value) (in // unmarshaling to, and when you recurse pass the reflect.Value for that // field back into this function. switch typedYAMLObj := yamlObj.(type) { - case map[interface{}]interface{}: + case map[any]any: // JSON does not support arbitrary keys in a map, so we must convert // these keys to strings. // // From my reading of go-yaml v2 (specifically the resolve function), // keys can only have the types string, int, int64, float64, binary // (unsupported), or null (unsupported). - strMap := make(map[string]interface{}) + strMap := make(map[string]any) for k, v := range typedYAMLObj { // Resolve the key to a string first. var keyString string @@ -259,10 +259,7 @@ func convertToJSONableObject(yamlObj interface{}, jsonTarget *reflect.Value) (in } } return strMap, nil - case []interface{}: - // We need to recurse into arrays in case there are any - // map[interface{}]interface{}'s inside and to convert any - // numbers to strings. + case []any: // If jsonTarget is a slice (which it really should be), find the // thing it's going to map to. If it's not a slice, just pass nil @@ -279,7 +276,7 @@ func convertToJSONableObject(yamlObj interface{}, jsonTarget *reflect.Value) (in } // Make and use a new array. - arr := make([]interface{}, len(typedYAMLObj)) + arr := make([]any, len(typedYAMLObj)) for i, v := range typedYAMLObj { arr[i], err = convertToJSONableObject(v, jsonSliceElemValue) if err != nil { @@ -311,7 +308,7 @@ func convertToJSONableObject(yamlObj interface{}, jsonTarget *reflect.Value) (in } } if len(s) > 0 { - yamlObj = interface{}(s) + yamlObj = any(s) } } return yamlObj, nil