Reputation: 371
The page Protocol Buffer Basics: Go says 2 things: 1) Download the package and follow instructions in README 2) Run go install google.golang.org/protobuf/cmd/protoc-gen-go Following the Download Protocol Buffers points to the release page which has tar and zip files for lots of languages (C++, C#, ...) but not Go. The file protobuf-all-3.12.3.tar.gz has many languages, but not Go. The README says for Go, head off to Go support for Protocol Buffers which says that it has been superseded by module google.golang.org/protobuf. There aren't any installation instructions by the time I've got there, just more general stuff pointing to even more pages. So I tried step (2)
go install google.golang.org/protobuf/cmd/protoc-gen-go
and got
can't load package: package google.golang.org/protobuf/cmd/protoc-gen-go: cannot find package "google.golang.org/protobuf/cmd/protoc-gen-go" in any of ...
I have 9 tabs open on my browser pointing to various Golang Protocol Buffer pages, and I still haven't managed to get going. I've downloaded protoc and got it working ok for Java and Python, but installing Go has got me beat so far. Is there a page that tells me what to do, in a simple way? Once upon a time using the Github repository it was easy, but that was long ago... Thanks, Jan
Upvotes: 9
Views: 10676
Reputation: 11
As pointed out in @jeremyko's comment, you will need Go 1.16 or higher. I personally installed Go from the APT repository, which often has outdated packages. It installed 1.13, so I had problems with installing OpenSnitch.
You can download the latest version from here.
Upvotes: 1
Reputation: 408
see this. https://developers.google.com/protocol-buffers/docs/reference/go-generated
you need go version 1.16 or higher. check that.
Upvotes: 1
Reputation: 22933
Make sure you have a go.mod
:
go mod init github.com/org/repo
Upvotes: 2
Reputation: 371
Running
go get -u google.golang.org/protobuf/cmd/protoc-gen-go
first before go install seems to have solved it.
Upvotes: 15
Reputation: 4491
protoc
binary for required OS: github.com => protobuf => releasesprotoc
to $PATH
protoc-gen-go
to $GOBIN
:user ~ % go install github.com/golang/protobuf/protoc-gen-go
go: finding github.com/golang/protobuf/protoc-gen-go latest
go: downloading google.golang.org/protobuf v1.23.0
go: extracting google.golang.org/protobuf v1.23.0
go: finding google.golang.org/protobuf v1.23.0
Note: to specific version add @v
+ version
Note: Go
Automatically install protoc-gen-go
binary to $GOBIN
, if $GOBIN
did not set, it's equals $GOPATH/bin
.
Upvotes: 1
Reputation: 1441
Have you tried installing the binary with the below command:
go install github.com/golang/protobuf/protoc-gen-go
If you are looking for a specific version, try:
go install github.com/golang/protobuf/[email protected]
Note: Make sure you set the GOBIN before you run the above commands
Thanks
Upvotes: 1