Protobuf: proto3 not support when use go mod

Created on 26 Dec 2018  路  11Comments  路  Source: golang/protobuf

Im using go1.11, run "go mod tidy" and it download v1.2.0(the latest tag), but it not support proto3!
broken with " undefined: proto.ProtoPackageIsVersion3" when build.

question

Most helpful comment

  1. go get github.com/golang/protobuf@master
  2. go mod vendor re-vendor

Things work fine for me.

If you are not sure, you can open go.mod, checkout the version tag of github.com/golang/protobuf should be v0.0.0 ..., and you can find ProtoPackageIsVersion3 = true in the proto/lib.go, if you have vendor directory in your project, check it first. That will be fine.

All 11 comments

Go modules only manages Go package dependencies, and not binary dependencies. This is almost certainly happening because you are using a version of protoc-gen-go that is beyond v1.2.0. Follow the directions in https://github.com/golang/protobuf#installation for how to install a particular version of protoc-gen-go. Let me know if this still doesn't work.

Not sure why this is closed. A common pattern is to include build tool dependencies in some tools.go file with a build tag excluding it from the regular builds, but still allowing you to control the exact versions. Then using go install installs all the build tools of the specific versions, making builds more or less environment-independent. Example: https://github.com/golang/go/issues/25922

Here the latest tag in protobuf is far from being actually the latest, and go get with modules enabled downloads version 1.2.0, which is often not what's expected. I would suggest re-opening this issue until the recent up-to-date version gets a proper git tag.

Note that the title of this issue is wrong: The up-to-date version is 1.2.0, which supports proto3. The version of the package including the symbol ProtoPackageIsVersion3 is unreleased; that symbol refers (admittedly confusingly) to a revision of the proto package's internal support API and not the version 3 protocol buffer specification.

@neild

There is only 1 and 2 in 1.2.0

screen shot 2019-01-08 at 5 46 55 pm

You really should add a new tag
I can install right version protoc-gen-go but not every one
When I use [email protected] ,it run error: undefined: proto.ProtoPackageIsVersion3

Build error still present undefined: proto.ProtoPackageIsVersion3

I have the same problem.

I use a temporary workaround
Run:

go get github.com/golang/protobuf@master

this will update your go modules to use master branch, and the build will work fine.

  1. go get github.com/golang/protobuf@master
  2. go mod vendor re-vendor

Things work fine for me.

If you are not sure, you can open go.mod, checkout the version tag of github.com/golang/protobuf should be v0.0.0 ..., and you can find ProtoPackageIsVersion3 = true in the proto/lib.go, if you have vendor directory in your project, check it first. That will be fine.

I just ran into this as well, as a first time user of proto and go. I think you should reopen this bug, because the install instructions from your website plainly don't work.

@jiusanzhou

  1. go get github.com/golang/protobuf@master

Produce this: go: cannot use path@version syntax in GOPATH mode

@jiusanzhou

  1. go get github.com/golang/protobuf@master

Produce this: go: cannot use path@version syntax in GOPATH mode

Looks like your project in GOPATH directory. You can try to enable gomod with command export GO111MODULE=on

Was this page helpful?
0 / 5 - 0 ratings