From a2d130f767761f9f7ffbc19e699129693ab8b07c Mon Sep 17 00:00:00 2001 From: Marko Date: Mon, 12 Aug 2024 15:12:22 +0200 Subject: [PATCH] refactor: use structural type for AnyResolver & Message (#144) --- CHANGELOG.md | 4 ++++ jsonpb/jsonpb.go | 2 +- proto/lib.go | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eba6cd33..18898912 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Improvments + +[#144](https://github.com/cosmos/gogoproto/pull/144) Change proto.Message and jsonpb.Anyresolver to aliased types to allow different implementations of the same interface. + ## [v1.6.0](https://github.com/cosmos/gogoproto/releases/tag/v1.6.0) - 2024-08-08 - [#142](https://github.com/cosmos/gogoproto/pull/142) Update code generator to make grpc `ServiceDesc` public. diff --git a/jsonpb/jsonpb.go b/jsonpb/jsonpb.go index cd812048..f7e88d69 100644 --- a/jsonpb/jsonpb.go +++ b/jsonpb/jsonpb.go @@ -88,7 +88,7 @@ type Marshaler struct { // AnyResolver takes a type URL, present in an Any message, and resolves it into // an instance of the associated message. -type AnyResolver interface { +type AnyResolver = interface { Resolve(typeUrl string) (proto.Message, error) } diff --git a/proto/lib.go b/proto/lib.go index 463c86d5..e94da451 100644 --- a/proto/lib.go +++ b/proto/lib.go @@ -335,7 +335,7 @@ func (nf *nonFatal) Merge(err error) (ok bool) { } // Message is implemented by generated protocol buffer messages. -type Message interface { +type Message = interface { Reset() String() string ProtoMessage()