Protobuf: github.com/protocolbuffers/protobuf: update canonical import paths of well-known types

Created on 13 Feb 2020  路  4Comments  路  Source: golang/protobuf

What version of protobuf and what language are you using?

protoc-gen-go v1.19.0-devel
protoc        v3.11.3

What did you do?
Generating google/rps/status.proto which contains import "google/protobuf/any.proto";

What did you expect to see?
Go import of "google.golang.org/protobuf/types/known/anypb"

What did you see instead?
Go import of "github.com/golang/protobuf/ptypes/any"

Anything else we should know about your project / environment?
protoc -I=. --go_out=:. google/api/*

post-release

All 4 comments

The google.golang.org/protobuf module isn't released yet. (Soon! Very, very soon!)

When it is, we will update google/protobuf/any.proto to point to the new import path and make the old package forward to the new one.

The Go import path used for any.proto is determined by the go_package option in the any.proto file itself, which is located in the https://github.com/protocolbuffers/protobuf project. Since that is a different project from this one, it is fundamentally impossible to atomically release both projects simultaneously.

The initial release of APIv2 will still produce Go import paths to the old "github.com/golang/protobuf/ptypes/any" package, and will be fixed when any.proto is updated and a new release of the protobuf toolchain is made.

I should note that the old "github.com/golang/protobuf/ptypes/any" package will forward everything to "google.golang.org/protobuf/types/known/anypb", so it won't really matter which package is being imported.

Renaming the issue to reflect the fact that we need to update the go_package option in relevant .proto files in the protobuf toolchain. This issue does not block v2 release since v2 needs to be released first, then the protobuf toolchain be updated shortly afterwards.

After doing so, we can remove the hacks in our integration tests to work around this issue: https://github.com/golang/protobuf/blob/709e7c8474b1872537f6062d469dda2899b8f338/integration_test.go#L320-L377

Was this page helpful?
0 / 5 - 0 ratings