for motivation: https://github.com/googleapis/toolkit/issues/324
@tmc Does it mean we can expect that compiled version of annotations.proto will be available in google/go-genproto?
@yugui yes that is the case.
For example, with just $GOPATH/src included in protoc -I I can now reference annotations like so: import "google.golang.org/genproto/googleapis/api/serviceconfig/annotations.proto"
and google.golang.org/genproto/googleapis/api/serviceconfig/annotations.pb.go exists.
https://github.com/grpc-ecosystem/grpc-gateway/tree/cleanup/use-go-genproto
I tried to move them, but it turned out that there's an compatibility issue.
Both google.golang.org/genproto/googleapis/api/serviceconfig and github.com/golang/protobuf/protoc-gen-go/plugin have references to their own version of descriptor.proto. They cannot coexist because the two instances of descriptor.pb.go collide with each other.
panic: proto: duplicate enum registered: google.protobuf.FieldDescriptorProto_Type
goroutine 1 [running]:
panic(0x1c89c0, 0xc42000c7e0)
/usr/local/Cellar/go/1.7/libexec/src/runtime/panic.go:500 +0x1a1
github.com/golang/protobuf/proto.RegisterEnum(0x228685, 0x29, 0xc4200106f0, 0xc420010720)
/Users/yugui/gengo/go/src/github.com/golang/protobuf/proto/properties.go:815 +0x13a
google.golang.org/genproto/protobuf.init.3()
/Users/yugui/gengo/go/src/google.golang.org/genproto/protobuf/descriptor.pb.go:1888 +0x4d0
google.golang.org/genproto/protobuf.init()
/Users/yugui/gengo/go/src/google.golang.org/genproto/protobuf/type.pb.go:394 +0xa67
google.golang.org/genproto/googleapis/api/serviceconfig.init()
/Users/yugui/gengo/go/src/google.golang.org/genproto/googleapis/api/serviceconfig/usage.pb.go:189 +0x58
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor.init()
/Users/yugui/gengo/go/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor/types.go:323 +0x76
main.init()
/Users/yugui/gengo/go/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/main.go:119 +0x71
panic: proto: duplicate extension registered: descriptor.MethodOptions 72295728
I had this error when using the google datastore go library together with grpc-gateway.
I solved it like this:
thirdparty folder from my vendor/ protoc -I"${GOPATH}/src" \
-I"${PWD}/vendor/github.com/googleapis/googleapis" \
--go_out=plugins=grpc:"${GOPATH}/src" \
Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/apiHope this helps in case anyone else is experiencing this.
genproto doesn't include proto files anymore so we need to keep vendoring -- #325 updates protos and includes the appropriate lines to rely on genproto for go files.
Most helpful comment
I had this error when using the google datastore go library together with grpc-gateway.
I solved it like this:
thirdpartyfolder from myvendor/Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/apiHope this helps in case anyone else is experiencing this.