Grpc-gateway: Move to google.golang.org/genproto instead of shipping annotations.proto.

Created on 26 Jul 2016  路  6Comments  路  Source: grpc-ecosystem/grpc-gateway

Most helpful comment

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:

  1. remove grpc gateways thirdparty folder from my vendor/
  2. go get github.com/googleapis/googleapis
  3. change protoc command to
    protoc  -I"${GOPATH}/src" \
        -I"${PWD}/vendor/github.com/googleapis/googleapis" \
        --go_out=plugins=grpc:"${GOPATH}/src" \
  • remove Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api
  • change import path

Hope this helps in case anyone else is experiencing this.

All 6 comments

@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:

  1. remove grpc gateways thirdparty folder from my vendor/
  2. go get github.com/googleapis/googleapis
  3. change protoc command to
    protoc  -I"${GOPATH}/src" \
        -I"${PWD}/vendor/github.com/googleapis/googleapis" \
        --go_out=plugins=grpc:"${GOPATH}/src" \
  • remove Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api
  • change import path

Hope 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.

Was this page helpful?
0 / 5 - 0 ratings