chore: run modernize (#24356)
This commit is contained in:
+22
-22
@@ -37,7 +37,7 @@ func RegisterEvidences(cdc *LegacyAmino) {
|
||||
// MarshalJSONIndent provides a utility for indented JSON encoding of an object
|
||||
// via an Amino codec. It returns an error if it cannot serialize or indent as
|
||||
// JSON.
|
||||
func MarshalJSONIndent(cdc *LegacyAmino, obj interface{}) ([]byte, error) {
|
||||
func MarshalJSONIndent(cdc *LegacyAmino, obj any) ([]byte, error) {
|
||||
bz, err := cdc.MarshalJSON(obj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -51,7 +51,7 @@ func MarshalJSONIndent(cdc *LegacyAmino, obj interface{}) ([]byte, error) {
|
||||
}
|
||||
|
||||
// MustMarshalJSONIndent executes MarshalJSONIndent except it panics upon failure.
|
||||
func MustMarshalJSONIndent(cdc *LegacyAmino, obj interface{}) []byte {
|
||||
func MustMarshalJSONIndent(cdc *LegacyAmino, obj any) []byte {
|
||||
bz, err := MarshalJSONIndent(cdc, obj)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("failed to marshal JSON: %s", err))
|
||||
@@ -60,23 +60,23 @@ func MustMarshalJSONIndent(cdc *LegacyAmino, obj interface{}) []byte {
|
||||
return bz
|
||||
}
|
||||
|
||||
func (cdc *LegacyAmino) marshalAnys(o interface{}) error {
|
||||
func (cdc *LegacyAmino) marshalAnys(o any) error {
|
||||
return types.UnpackInterfaces(o, types.AminoPacker{Cdc: cdc.Amino})
|
||||
}
|
||||
|
||||
func (cdc *LegacyAmino) unmarshalAnys(o interface{}) error {
|
||||
func (cdc *LegacyAmino) unmarshalAnys(o any) error {
|
||||
return types.UnpackInterfaces(o, types.AminoUnpacker{Cdc: cdc.Amino})
|
||||
}
|
||||
|
||||
func (cdc *LegacyAmino) jsonMarshalAnys(o interface{}) error {
|
||||
func (cdc *LegacyAmino) jsonMarshalAnys(o any) error {
|
||||
return types.UnpackInterfaces(o, types.AminoJSONPacker{Cdc: cdc.Amino})
|
||||
}
|
||||
|
||||
func (cdc *LegacyAmino) jsonUnmarshalAnys(o interface{}) error {
|
||||
func (cdc *LegacyAmino) jsonUnmarshalAnys(o any) error {
|
||||
return types.UnpackInterfaces(o, types.AminoJSONUnpacker{Cdc: cdc.Amino})
|
||||
}
|
||||
|
||||
func (cdc *LegacyAmino) Marshal(o interface{}) ([]byte, error) {
|
||||
func (cdc *LegacyAmino) Marshal(o any) ([]byte, error) {
|
||||
err := cdc.marshalAnys(o)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -84,7 +84,7 @@ func (cdc *LegacyAmino) Marshal(o interface{}) ([]byte, error) {
|
||||
return cdc.Amino.MarshalBinaryBare(o)
|
||||
}
|
||||
|
||||
func (cdc *LegacyAmino) MustMarshal(o interface{}) []byte {
|
||||
func (cdc *LegacyAmino) MustMarshal(o any) []byte {
|
||||
bz, err := cdc.Marshal(o)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -92,7 +92,7 @@ func (cdc *LegacyAmino) MustMarshal(o interface{}) []byte {
|
||||
return bz
|
||||
}
|
||||
|
||||
func (cdc *LegacyAmino) MarshalLengthPrefixed(o interface{}) ([]byte, error) {
|
||||
func (cdc *LegacyAmino) MarshalLengthPrefixed(o any) ([]byte, error) {
|
||||
err := cdc.marshalAnys(o)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -100,7 +100,7 @@ func (cdc *LegacyAmino) MarshalLengthPrefixed(o interface{}) ([]byte, error) {
|
||||
return cdc.Amino.MarshalBinaryLengthPrefixed(o)
|
||||
}
|
||||
|
||||
func (cdc *LegacyAmino) MustMarshalLengthPrefixed(o interface{}) []byte {
|
||||
func (cdc *LegacyAmino) MustMarshalLengthPrefixed(o any) []byte {
|
||||
bz, err := cdc.MarshalLengthPrefixed(o)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -108,7 +108,7 @@ func (cdc *LegacyAmino) MustMarshalLengthPrefixed(o interface{}) []byte {
|
||||
return bz
|
||||
}
|
||||
|
||||
func (cdc *LegacyAmino) Unmarshal(bz []byte, ptr interface{}) error {
|
||||
func (cdc *LegacyAmino) Unmarshal(bz []byte, ptr any) error {
|
||||
err := cdc.Amino.UnmarshalBinaryBare(bz, ptr)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -116,14 +116,14 @@ func (cdc *LegacyAmino) Unmarshal(bz []byte, ptr interface{}) error {
|
||||
return cdc.unmarshalAnys(ptr)
|
||||
}
|
||||
|
||||
func (cdc *LegacyAmino) MustUnmarshal(bz []byte, ptr interface{}) {
|
||||
func (cdc *LegacyAmino) MustUnmarshal(bz []byte, ptr any) {
|
||||
err := cdc.Unmarshal(bz, ptr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (cdc *LegacyAmino) UnmarshalLengthPrefixed(bz []byte, ptr interface{}) error {
|
||||
func (cdc *LegacyAmino) UnmarshalLengthPrefixed(bz []byte, ptr any) error {
|
||||
err := cdc.Amino.UnmarshalBinaryLengthPrefixed(bz, ptr)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -131,7 +131,7 @@ func (cdc *LegacyAmino) UnmarshalLengthPrefixed(bz []byte, ptr interface{}) erro
|
||||
return cdc.unmarshalAnys(ptr)
|
||||
}
|
||||
|
||||
func (cdc *LegacyAmino) MustUnmarshalLengthPrefixed(bz []byte, ptr interface{}) {
|
||||
func (cdc *LegacyAmino) MustUnmarshalLengthPrefixed(bz []byte, ptr any) {
|
||||
err := cdc.UnmarshalLengthPrefixed(bz, ptr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -139,7 +139,7 @@ func (cdc *LegacyAmino) MustUnmarshalLengthPrefixed(bz []byte, ptr interface{})
|
||||
}
|
||||
|
||||
// MarshalJSON implements codec.Codec interface
|
||||
func (cdc *LegacyAmino) MarshalJSON(o interface{}) ([]byte, error) {
|
||||
func (cdc *LegacyAmino) MarshalJSON(o any) ([]byte, error) {
|
||||
err := cdc.jsonMarshalAnys(o)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -147,7 +147,7 @@ func (cdc *LegacyAmino) MarshalJSON(o interface{}) ([]byte, error) {
|
||||
return cdc.Amino.MarshalJSON(o)
|
||||
}
|
||||
|
||||
func (cdc *LegacyAmino) MustMarshalJSON(o interface{}) []byte {
|
||||
func (cdc *LegacyAmino) MustMarshalJSON(o any) []byte {
|
||||
bz, err := cdc.MarshalJSON(o)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -156,7 +156,7 @@ func (cdc *LegacyAmino) MustMarshalJSON(o interface{}) []byte {
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements codec.Codec interface
|
||||
func (cdc *LegacyAmino) UnmarshalJSON(bz []byte, ptr interface{}) error {
|
||||
func (cdc *LegacyAmino) UnmarshalJSON(bz []byte, ptr any) error {
|
||||
err := cdc.Amino.UnmarshalJSON(bz, ptr)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -164,26 +164,26 @@ func (cdc *LegacyAmino) UnmarshalJSON(bz []byte, ptr interface{}) error {
|
||||
return cdc.jsonUnmarshalAnys(ptr)
|
||||
}
|
||||
|
||||
func (cdc *LegacyAmino) MustUnmarshalJSON(bz []byte, ptr interface{}) {
|
||||
func (cdc *LegacyAmino) MustUnmarshalJSON(bz []byte, ptr any) {
|
||||
err := cdc.UnmarshalJSON(bz, ptr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (*LegacyAmino) UnpackAny(*types.Any, interface{}) error {
|
||||
func (*LegacyAmino) UnpackAny(*types.Any, any) error {
|
||||
return errors.New("AminoCodec can't handle unpack protobuf Any's")
|
||||
}
|
||||
|
||||
func (cdc *LegacyAmino) RegisterInterface(ptr interface{}, iopts *amino.InterfaceOptions) {
|
||||
func (cdc *LegacyAmino) RegisterInterface(ptr any, iopts *amino.InterfaceOptions) {
|
||||
cdc.Amino.RegisterInterface(ptr, iopts)
|
||||
}
|
||||
|
||||
func (cdc *LegacyAmino) RegisterConcrete(o interface{}, name string, copts *amino.ConcreteOptions) {
|
||||
func (cdc *LegacyAmino) RegisterConcrete(o any, name string, copts *amino.ConcreteOptions) {
|
||||
cdc.Amino.RegisterConcrete(o, name, copts)
|
||||
}
|
||||
|
||||
func (cdc *LegacyAmino) MarshalJSONIndent(o interface{}, prefix, indent string) ([]byte, error) {
|
||||
func (cdc *LegacyAmino) MarshalJSONIndent(o any, prefix, indent string) ([]byte, error) {
|
||||
err := cdc.jsonMarshalAnys(o)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@@ -104,7 +104,7 @@ func (ac *AminoCodec) MarshalInterface(i proto.Message) ([]byte, error) {
|
||||
//
|
||||
// var x MyInterface
|
||||
// err := cdc.UnmarshalInterface(bz, &x)
|
||||
func (ac *AminoCodec) UnmarshalInterface(bz []byte, ptr interface{}) error {
|
||||
func (ac *AminoCodec) UnmarshalInterface(bz []byte, ptr any) error {
|
||||
return ac.LegacyAmino.Unmarshal(bz, ptr)
|
||||
}
|
||||
|
||||
@@ -126,6 +126,6 @@ func (ac *AminoCodec) MarshalInterfaceJSON(i proto.Message) ([]byte, error) {
|
||||
//
|
||||
// var x MyInterface
|
||||
// err := cdc.UnmarshalInterfaceJSON(bz, &x)
|
||||
func (ac *AminoCodec) UnmarshalInterfaceJSON(bz []byte, ptr interface{}) error {
|
||||
func (ac *AminoCodec) UnmarshalInterfaceJSON(bz []byte, ptr any) error {
|
||||
return ac.LegacyAmino.UnmarshalJSON(bz, ptr)
|
||||
}
|
||||
|
||||
+2
-2
@@ -72,7 +72,7 @@ type (
|
||||
// UnmarshalInterface is a helper method which will parse binary enoded data
|
||||
// into `Any` and unpack any into the `ptr`. It fails if the target interface type
|
||||
// is not registered in codec, or is not compatible with the serialized data
|
||||
UnmarshalInterface(bz []byte, ptr interface{}) error
|
||||
UnmarshalInterface(bz []byte, ptr any) error
|
||||
|
||||
types.AnyUnpacker
|
||||
}
|
||||
@@ -88,7 +88,7 @@ type (
|
||||
// UnmarshalInterfaceJSON is a helper method which will parse JSON enoded data
|
||||
// into `Any` and unpack any into the `ptr`. It fails if the target interface type
|
||||
// is not registered in codec, or is not compatible with the serialized data
|
||||
UnmarshalInterfaceJSON(bz []byte, ptr interface{}) error
|
||||
UnmarshalInterfaceJSON(bz []byte, ptr any) error
|
||||
|
||||
// UnmarshalJSON parses the data encoded with MarshalJSON method and stores the result
|
||||
// in the value pointed to by v.
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
type interfaceMarshaler struct {
|
||||
marshal func(i proto.Message) ([]byte, error)
|
||||
unmarshal func(bz []byte, ptr interface{}) error
|
||||
unmarshal func(bz []byte, ptr any) error
|
||||
}
|
||||
|
||||
func testInterfaceMarshaling(require *require.Assertions, cdc interfaceMarshaler, isAminoBin bool) {
|
||||
|
||||
@@ -248,7 +248,7 @@ func (pc *ProtoCodec) MarshalInterface(i gogoproto.Message) ([]byte, error) {
|
||||
//
|
||||
// var x MyInterface
|
||||
// err := cdc.UnmarshalInterface(bz, &x)
|
||||
func (pc *ProtoCodec) UnmarshalInterface(bz []byte, ptr interface{}) error {
|
||||
func (pc *ProtoCodec) UnmarshalInterface(bz []byte, ptr any) error {
|
||||
any := &types.Any{}
|
||||
err := pc.Unmarshal(bz, any)
|
||||
if err != nil {
|
||||
@@ -278,7 +278,7 @@ func (pc *ProtoCodec) MarshalInterfaceJSON(x gogoproto.Message) ([]byte, error)
|
||||
//
|
||||
// var x MyInterface // must implement proto.Message
|
||||
// err := cdc.UnmarshalInterfaceJSON(&x, bz)
|
||||
func (pc *ProtoCodec) UnmarshalInterfaceJSON(bz []byte, iface interface{}) error {
|
||||
func (pc *ProtoCodec) UnmarshalInterfaceJSON(bz []byte, iface any) error {
|
||||
any := &types.Any{}
|
||||
err := pc.UnmarshalJSON(bz, any)
|
||||
if err != nil {
|
||||
@@ -290,7 +290,7 @@ func (pc *ProtoCodec) UnmarshalInterfaceJSON(bz []byte, iface interface{}) error
|
||||
// UnpackAny implements AnyUnpacker.UnpackAny method,
|
||||
// it unpacks the value in any to the interface pointer passed in as
|
||||
// iface.
|
||||
func (pc *ProtoCodec) UnpackAny(any *types.Any, iface interface{}) error {
|
||||
func (pc *ProtoCodec) UnpackAny(any *types.Any, iface any) error {
|
||||
return pc.interfaceRegistry.UnpackAny(any, iface)
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ type grpcProtoCodec struct {
|
||||
cdc *ProtoCodec
|
||||
}
|
||||
|
||||
func (g grpcProtoCodec) Marshal(v interface{}) ([]byte, error) {
|
||||
func (g grpcProtoCodec) Marshal(v any) ([]byte, error) {
|
||||
switch m := v.(type) {
|
||||
case proto.Message:
|
||||
protov2MarshalOpts := proto.MarshalOptions{Deterministic: true}
|
||||
@@ -354,7 +354,7 @@ func (g grpcProtoCodec) Marshal(v interface{}) ([]byte, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (g grpcProtoCodec) Unmarshal(data []byte, v interface{}) error {
|
||||
func (g grpcProtoCodec) Unmarshal(data []byte, v any) error {
|
||||
switch m := v.(type) {
|
||||
case proto.Message:
|
||||
return proto.Unmarshal(data, m)
|
||||
@@ -369,7 +369,7 @@ func (g grpcProtoCodec) Name() string {
|
||||
return "cosmos-sdk-grpc-codec"
|
||||
}
|
||||
|
||||
func assertNotNil(i interface{}) error {
|
||||
func assertNotNil(i any) error {
|
||||
if i == nil {
|
||||
return errors.New("can't marshal <nil> value")
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ func TestProtoCodecMarshal(t *testing.T) {
|
||||
|
||||
// Emulate grpc server implementation
|
||||
// https://github.com/grpc/grpc-go/blob/b1d7f56b81b7902d871111b82dec6ba45f854ede/rpc_util.go#L590
|
||||
func grpcServerEncode(c encoding.Codec, msg interface{}) ([]byte, error) {
|
||||
func grpcServerEncode(c encoding.Codec, msg any) ([]byte, error) {
|
||||
if msg == nil { // NOTE: typed nils will not be caught by this check
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package types_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
)
|
||||
|
||||
type errOnMarshal struct {
|
||||
testdata.Dog
|
||||
}
|
||||
|
||||
var _ proto.Message = (*errOnMarshal)(nil)
|
||||
|
||||
var errAlways = fmt.Errorf("always erroring")
|
||||
|
||||
func (eom *errOnMarshal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return nil, errAlways
|
||||
}
|
||||
|
||||
var eom = &errOnMarshal{}
|
||||
|
||||
// Ensure that returning an error doesn't suddenly allocate and waste bytes.
|
||||
// See https://github.com/cosmos/cosmos-sdk/issues/8537
|
||||
func TestNewAnyWithCustomTypeURLWithErrorNoAllocation(t *testing.T) {
|
||||
// This tests continues to fail inconsistently.
|
||||
//
|
||||
// Example: https://github.com/cosmos/cosmos-sdk/pull/9246/checks?check_run_id=2643313958#step:6:118
|
||||
// Ref: https://github.com/cosmos/cosmos-sdk/issues/9010
|
||||
t.SkipNow()
|
||||
|
||||
// make sure we're not in the middle of a GC.
|
||||
runtime.GC()
|
||||
|
||||
var ms1, ms2 runtime.MemStats
|
||||
runtime.ReadMemStats(&ms1)
|
||||
any, err := types.NewAnyWithValue(eom)
|
||||
runtime.ReadMemStats(&ms2)
|
||||
// Ensure that no fresh allocation was made.
|
||||
if diff := ms2.HeapAlloc - ms1.HeapAlloc; diff > 0 {
|
||||
t.Errorf("Unexpected allocation of %d bytes", diff)
|
||||
}
|
||||
if err == nil {
|
||||
t.Fatal("err wasn't returned")
|
||||
}
|
||||
if any != nil {
|
||||
t.Fatalf("Unexpectedly got a non-nil Any value: %v", any)
|
||||
}
|
||||
}
|
||||
|
||||
var sink any
|
||||
|
||||
func BenchmarkNewAnyWithCustomTypeURLWithErrorReturned(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
any, err := types.NewAnyWithValue(eom)
|
||||
if err == nil {
|
||||
b.Fatal("err wasn't returned")
|
||||
}
|
||||
if any != nil {
|
||||
b.Fatalf("Unexpectedly got a non-nil Any value: %v", any)
|
||||
}
|
||||
sink = any
|
||||
}
|
||||
if sink == nil {
|
||||
b.Fatal("benchmark didn't run")
|
||||
}
|
||||
sink = (any)(nil)
|
||||
}
|
||||
@@ -19,5 +19,5 @@ type AminoJSONUnpacker = gogoany.AminoJSONUnpacker
|
||||
// AminoJSONPacker is an alias for github.com/cosmos/gogoproto/types/any.AminoJSONPacker.
|
||||
type AminoJSONPacker = gogoany.AminoJSONPacker
|
||||
|
||||
// ProtoUnpacker is an alias for github.com/cosmos/gogoproto/types/any.ProtoJSONPacker.
|
||||
// ProtoJSONPacker is an alias for github.com/cosmos/gogoproto/types/any.ProtoJSONPacker.
|
||||
type ProtoJSONPacker = gogoany.ProtoJSONPacker
|
||||
|
||||
@@ -54,14 +54,14 @@ type InterfaceRegistry interface {
|
||||
//
|
||||
// Ex:
|
||||
// registry.RegisterInterface("cosmos.base.v1beta1.Msg", (*sdk.Msg)(nil))
|
||||
RegisterInterface(protoName string, iface interface{}, impls ...proto.Message)
|
||||
RegisterInterface(protoName string, iface any, impls ...proto.Message)
|
||||
|
||||
// RegisterImplementations registers impls as concrete implementations of
|
||||
// the interface iface.
|
||||
//
|
||||
// Ex:
|
||||
// registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSend{}, &MsgMultiSend{})
|
||||
RegisterImplementations(iface interface{}, impls ...proto.Message)
|
||||
RegisterImplementations(iface any, impls ...proto.Message)
|
||||
|
||||
// ListAllInterfaces list the type URLs of all registered interfaces.
|
||||
ListAllInterfaces() []string
|
||||
@@ -71,7 +71,7 @@ type InterfaceRegistry interface {
|
||||
ListImplementations(ifaceTypeURL string) []string
|
||||
|
||||
// EnsureRegistered ensures there is a registered interface for the given concrete type.
|
||||
EnsureRegistered(iface interface{}) error
|
||||
EnsureRegistered(iface any) error
|
||||
|
||||
protodesc.Resolver
|
||||
|
||||
@@ -169,7 +169,7 @@ func NewInterfaceRegistryWithOptions(options InterfaceRegistryOptions) (Interfac
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (registry *interfaceRegistry) RegisterInterface(protoName string, iface interface{}, impls ...proto.Message) {
|
||||
func (registry *interfaceRegistry) RegisterInterface(protoName string, iface any, impls ...proto.Message) {
|
||||
typ := reflect.TypeOf(iface)
|
||||
if typ.Elem().Kind() != reflect.Interface {
|
||||
panic(fmt.Errorf("%T is not an interface type", iface))
|
||||
@@ -182,7 +182,7 @@ func (registry *interfaceRegistry) RegisterInterface(protoName string, iface int
|
||||
// EnsureRegistered ensures there is a registered interface for the given concrete type.
|
||||
//
|
||||
// Returns an error if not, and nil if so.
|
||||
func (registry *interfaceRegistry) EnsureRegistered(impl interface{}) error {
|
||||
func (registry *interfaceRegistry) EnsureRegistered(impl any) error {
|
||||
if reflect.ValueOf(impl).Kind() != reflect.Ptr {
|
||||
return fmt.Errorf("%T is not a pointer", impl)
|
||||
}
|
||||
@@ -199,7 +199,7 @@ func (registry *interfaceRegistry) EnsureRegistered(impl interface{}) error {
|
||||
//
|
||||
// This function PANICs if different concrete types are registered under the
|
||||
// same typeURL.
|
||||
func (registry *interfaceRegistry) RegisterImplementations(iface interface{}, impls ...proto.Message) {
|
||||
func (registry *interfaceRegistry) RegisterImplementations(iface any, impls ...proto.Message) {
|
||||
for _, impl := range impls {
|
||||
typeURL := MsgTypeURL(impl)
|
||||
registry.registerImpl(iface, typeURL, impl)
|
||||
@@ -211,7 +211,7 @@ func (registry *interfaceRegistry) RegisterImplementations(iface interface{}, im
|
||||
//
|
||||
// This function PANICs if different concrete types are registered under the
|
||||
// same typeURL.
|
||||
func (registry *interfaceRegistry) RegisterCustomTypeURL(iface interface{}, typeURL string, impl proto.Message) {
|
||||
func (registry *interfaceRegistry) RegisterCustomTypeURL(iface any, typeURL string, impl proto.Message) {
|
||||
registry.registerImpl(iface, typeURL, impl)
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ func (registry *interfaceRegistry) RegisterCustomTypeURL(iface interface{}, type
|
||||
//
|
||||
// This function PANICs if different concrete types are registered under the
|
||||
// same typeURL.
|
||||
func (registry *interfaceRegistry) registerImpl(iface interface{}, typeURL string, impl proto.Message) {
|
||||
func (registry *interfaceRegistry) registerImpl(iface any, typeURL string, impl proto.Message) {
|
||||
ityp := reflect.TypeOf(iface).Elem()
|
||||
imap, found := registry.interfaceImpls[ityp]
|
||||
if !found {
|
||||
@@ -283,7 +283,7 @@ func (registry *interfaceRegistry) ListImplementations(ifaceName string) []strin
|
||||
return keys
|
||||
}
|
||||
|
||||
func (registry *interfaceRegistry) UnpackAny(any *Any, iface interface{}) error {
|
||||
func (registry *interfaceRegistry) UnpackAny(any *Any, iface any) error {
|
||||
unpacker := &statefulUnpacker{
|
||||
registry: registry,
|
||||
maxDepth: MaxUnpackAnyRecursionDepth,
|
||||
|
||||
Reference in New Issue
Block a user