Skip to content
New issue

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

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

Already on GitHub? # to your account

Update proto package imports to google.golang.org/protobuf/proto #3554

Closed
EricMasonFa opened this issue Apr 21, 2020 · 10 comments
Closed

Update proto package imports to google.golang.org/protobuf/proto #3554

EricMasonFa opened this issue Apr 21, 2020 · 10 comments
Labels

Comments

@EricMasonFa
Copy link

What version of gRPC are you using?

1.28.1

What version of Go are you using (go version)?

go1.13.5 darwin/amd64

What operating system (Linux, Windows, …) and version?

Mac - Catalina

What did you do?

Moved from "github.com/golang/protobuf/proto" to "google.golang.org/protobuf/proto"

What did you expect to see?

Compatibility with grpc-go.

What did you see instead?

WithDetails is expecting github.com/golang/protobuf/proto.Message while thir documentation says that package is depricated.

@dfawley dfawley added P2 Type: Feature New features or improvements in behavior and removed Type: Bug labels Apr 23, 2020
@easwars
Copy link
Contributor

easwars commented Apr 23, 2020

To change the protobuf API that gRPC depends on will be a big undertaking and the team currently does not have the resources to dedicate to it. We also need to make sure that none of our users are broken as we try to make this switch.

@alexshtin
Copy link

I am wondering how many people use protobuf w/o gRPC? Because lack of gRPC support actually makes this release useless.

@odsod
Copy link

odsod commented Apr 29, 2020

@alexshtin You can use the protoc-gen-go generator from the v1.4.0 release of golang/protobuf to generate v2 forward-compatible proto and gRPC stubs.

@JoelPM
Copy link

JoelPM commented Apr 29, 2020

@odsod - apologies if this is a newbie question, but could you provide more details on how to do so? After installing and using v1.4.0 of protoc-gen-go I still get errors ("missing ProtoReflect method") when attempting to use generated types with the google.golang.org/protobuf import. The generated types still import github.com/golang/protobuf/proto. It's very possible I did something wrong.

EDIT: Nevermind, I was doing it wrong. I checked out the v1.4.0 tag, built it, and generated the golang bindings using that version of protoc-gen-go. At that point I was able to use google.golang.org/protobuf

@alexshtin
Copy link

I am really confused about these 2 go packages. I've just tried to generate go code from my proto files using go install github.com/golang/protobuf/protoc-gen-go and go install google.golang.org/protobuf/cmd/protoc-gen-go. The only difference is version in the header:

github.com/golang/protobuf/protoc-gen-go:

// 	protoc-gen-go v1.23.0

google.golang.org/protobuf/cmd/protoc-gen-go:

// 	protoc-gen-go v1.23.0-devel

And yes, the first one supports gRPC plugin and the second one doesn't. Am I right that both generators are using "...second major revision of the Go protocol buffer API implemented by the google.golang.org/protobuf module." ?

Also noticed that https://github.com/protocolbuffers/protobuf-go/blob/master/go.mod and https://github.com/golang/protobuf/blob/master/go.mod are cross referencing each other. I didn't know that it is even possible.

@neild
Copy link
Contributor

neild commented Jun 23, 2020

google.golang.org/protobuf/cmd/protoc-gen-go is the most recent version of the Go protobuf compiler. We (the protobuf devs) recommend using it.

This version of protoc-gen-go does not include support for generating gRPC service definitions. gRPC generation has moved to google.golang.org/grpc/cmd/protoc-gen-go-grpc.

github.com/golang/protobuf/protoc-gen-go v1.4 and higher uses the same code generator as google.golang.org/protobuf/cmd/protoc-gen-go. The two versions produce the same output.

For backwards compatibility, github.com/golang/protobuf/protoc-gen-go includes support for some features which were dropped from the newer compiler, most notably the plugins=grpc flag. If you're currently using github.com/golang/protobuf/protoc-gen-go v1.3 or older, you can upgrade to v1.4 and get the newest code generator without making any other changes.

google.golang.org/grpc/cmd/protoc-gen-go-grpc is the newest gRPC service generator.

Edit: See below; protoc-gen-go-grpc isn't released yet. Use github.com/golang/protobuf/protoc-gen-go for generating gRPC service definitions for now.

By default, protoc-gen-go-grpc includes one backwards incompatible change from the gRPC generator in protoc-gen-go: service implementations must embed the Unimplemented<ServiceName>Server type. This behavior can be disabled with a flag; see:

https://github.com/grpc/grpc-go/blob/master/cmd/protoc-gen-go-grpc/README.md

The protoc-gen-go-grpc generator has just been released, and not all documentation has been updated to reference it. To use it:

OPTIONS=module=example.org/my/module  # or whatever options you need
protoc --go_opt=$OPTIONS --go-grpc_out=$OPTIONS --go_out=. --go-grpc_out=. path/to/foo.proto

Note that you need to pass any options to both code generators (--go_opt and --go-grpc_opt). This is unfortunate, but a limitation of protoc.

@dfawley
Copy link
Member

dfawley commented Jun 23, 2020

@neild, actually we are still iterating on protoc-gen-go-grpc (at v0, so backward incompatible changes may be possible). The gRPC team recommends using github.com/golang/protobuf/protoc-gen-go for generating gRPC services until protoc-gen-go-grpc is released as v1.0.

For more information and to track any potential changes, please see #3669.

@dfawley dfawley changed the title gRPC-go is using depricated package Update proto package imports to google.golang.org/protobuf/proto Oct 2, 2020
@mgabeler-lee-6rs
Copy link

github.com/golang/protobuf is now "officially" deprecated, and this package has released 1.x, but code generated from this package still uses those deprecated imports.

Perhaps it's time to revisit this issue? :)

@dfawley dfawley added P3 Status: Help Wanted Type: Internal Cleanup Refactors, etc and removed P2 Type: Feature New features or improvements in behavior labels Apr 2, 2021
@dfawley
Copy link
Member

dfawley commented Apr 2, 2021

This is a non-trivial change (I started an attempt at it awhile back, thinking it would be quick), and the benefits are questionable, considering the v1 library is implemented using v2. At this time, we have no plans to complete this.

@easwars
Copy link
Contributor

easwars commented May 4, 2021

Closing this due to lack of activity and priority.

@easwars easwars closed this as completed May 4, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 1, 2021
stpabhi added a commit to stpabhi/grpc-go that referenced this issue Nov 15, 2022
Fixes grpc#3554

Signed-off-by: Abhilash Pallerlamudi <stp.abhi@gmail.com>
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

No branches or pull requests

8 participants