Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

golanglint can't pass #463

Open
jianghuosiliuying opened this issue Nov 29, 2021 · 4 comments
Open

golanglint can't pass #463

jianghuosiliuying opened this issue Nov 29, 2021 · 4 comments

Comments

@jianghuosiliuying
Copy link

SA1019: package github.com/golang/protobuf/jsonpb is deprecated: Use the "google.golang.org/protobuf/encoding/protojson" package instead.

@jhump
Copy link
Owner

jhump commented Feb 5, 2022

I'm afraid I have no intention of changing this right now.

This package was built on top of the v1 API of the protobuf runtime, which are the packages in "github.com/golang/protobuf". I am aware that v1 is now deprecated.

I don't plan on addressing this until I create a v2 of this repo. The v2 of the protobuf runtime (in "google.golang.org/protobuf") is sufficiently different, and provides quite a lot of similar functionality now, that a version of this library that is built on top of the v2 (and thus doesn't suffer from these deprecation warnings) would not be backwards-compatible.

@btiernay
Copy link

Thanks for the explanation. Might be useful context to add to the main project README as if you are so inclined.

On a related topic, I'm wondering if you have any suggestions on general guidance on interop. For example, a code base I'm working in is heavily using v2 types internally. I am looking at your awesome library (thank you for all the great work!) as a way to be able to handle the processing of protobuf types dynamically. There is a need to convert from a the v1 proto.Message to the v2 proto.Message which the rest of the code base uses. Is there a pattern for that outside of rewriting to use v1? Thank you 🙇!

@jhump
Copy link
Owner

jhump commented Aug 1, 2022

@btiernay, sorry I never replied to that last comment. You can easily convert between the V1 and V2 message types using helper functions in the proto package of the V1 API. For example proto.MessageV1
accepts a V2 message and returns a V1 message type. There is also a proto.MessageV2 function which converts the other direction.

As far as using the protobuf types dynamically, the V1 API now provides support for that in its protoreflect and dynamicpb packages.

@jhump
Copy link
Owner

jhump commented Jan 22, 2024

@btiernay, you may have already seen it, but v1.15 introduced some major changes that should make interop between this module and the reflect/protoreflect stuff in google.golang.org/protobuf drastically better (almost all under-the-hood; almost nothing changed in the exported API).

It was a sizable change, and several regressions have been reported, which have been fixed in the subsequent patch releases. (In fact, I expect another 1.15.6 later this week, maybe even today.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants