8
1

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 で protocolbuf を使うと ProtoPackageIsVersion3 のエラーがでる件

Posted at

2019/1/10 時点での内容です。

概要

Go 1.11にて、Module(vgo)を利用している前提にて、以下のエラーが発生した場合の対処について記載しています。

xxx: undefined: proto.ProtoPackageIsVersion3

※ Module(vgo)モードではない場合は、以下の記事を参考にしてください。
https://qiita.com/go_sagawa/items/5ba0ebb0cf42a629e2e9

背景

何処かのタイミングで各種ライブラリをアップデートした際に、上記エラーが発生し、ビルドが通らなくなりました。
また、私のケースでは、Go 1.11のModule(vgo)を利用しているため、このケースでの解決方法について記載します。
以下にて、今回の問題が取り上げられています。
https://github.com/golang/protobuf/issues/763

対応方法

該当のディレクトリへ移動します。go.modを見てみると、以下のように v1.2.0 が入っています。

require (
	...
	github.com/gogo/protobuf v1.2.0
)

以下のコマンドにて、特定バージョンのmoduleを追加します。

go get github.com/golang/protobuf@8d0c54c1246661d9a51ca0ba455d22116d485eaa

もう一度、go.mod を見てみると、追加したmoduleを確認することができます。

require (
	...
	github.com/gogo/protobuf v1.2.0
	...
	github.com/golang/protobuf v1.2.1-0.20181127190454-8d0c54c12466
)

これでビルドエラーは解消されました。

8
1
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
8
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?