11
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

goでprotobufやgrpc-ecosystemを最新にしたらエラーが出るようになった件の対処

Last updated at Posted at 2018-12-11

#概要
表題の件の対処、ライブラリのダウングレード方法をまとめます。
このエラーは2018/12/10時点のもので、おそらく近く修正されるかと思うのですが直近同じエラーにはまった人や、ライブラリのダウンロード方法の参考になればと思い記事を残します。すぐエラーを直したい方は全ての実行コマンドを確認してください。

#経緯
以下のようにproto系のライブラリをアップデートすると、

brew upgrade protobuf
go get -u google.golang.org/grpc
go get -u github.com/golang/protobuf/proto
go get -u github.com/golang/protobuf/protoc-gen-go
go get -u go.pedge.io/protoeasy/cmd/protoeasy
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger

以下のエラーメッセージが出て今まで通っていたbuildが通らなくなりました。

xxxxx.pb.go:xx:xx: undefined: proto.ProtoPackageIsVersion3
xxxxx.pb.gw.go:xx:xx: undefined: utilities.IOReaderFactory

以下、同じエラーが出ている人がいたので、同様の対処方法を試みます

Rev of proto-gen-go to ProtoPackageIsVersion3 causing breakage
https://github.com/golang/protobuf/issues/763

cd $GOPATH/src/github.com/golang/protobuf/protoc-gen-go
git checkout v1.2.0
go install
git checkout master

再度、make protoしてmakeするとundefined: proto.ProtoPackageIsVersion3の方のエラーは消えたのですが、undefined: utilities.IOReaderFactoryの方は消えません。

こちらはpb.gw.goでgateway用のファイルのなので、gatewayの方もダウングレードします。

cd $GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
git checkout v1.5.1
go install
git checkout master

これでmake protoしてmakeするとエラーが出なくなりました。

バージョンの下げ方

対象フォルダに入って、旧バージョンをチェックアウトしgo installするだけですが、ブランチをmasterに戻しておかないと再度go get -u した時にエラーになるので戻しています。

cd $GOPATH/src/github.com/golang/protobuf/protoc-gen-go
git checkout v1.2.0
go install
git checkout master

全ての実行コマンド

brew upgrade protobuf
go get -u google.golang.org/grpc
go get -u github.com/golang/protobuf/proto
go get -u github.com/golang/protobuf/protoc-gen-go
go get -u go.pedge.io/protoeasy/cmd/protoeasy
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger

cd $GOPATH/src/github.com/golang/protobuf/protoc-gen-go
git checkout v1.2.0
go install
git checkout master

cd $GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
git checkout v1.5.1
go install
git checkout master
11
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?