Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot find package "google.golang.org/protobuf/cmd/protoc-gen-go"

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

like image 956
Jan Newmarch Avatar asked Jun 04 '20 08:06

Jan Newmarch


People also ask

How do you install protoc GEN Go in Windows?

Download protoc-win32. zip from https://developers.google.com/protocol-buffers/docs/downloads. Unzip and add location of the protoc.exe to your PATH environment variable. Run `protoc --version` from command prompt to verify.

What is protoc GEN Go Grpc?

This tool generates Go language bindings of service s in protobuf definition files for gRPC. For usage information, please see our quick start guide.


2 Answers

Running

go get -u google.golang.org/protobuf/cmd/protoc-gen-go

first before go install seems to have solved it.

like image 114
Jan Newmarch Avatar answered Nov 12 '22 04:11

Jan Newmarch


Make sure you have a go.mod:

go mod init github.com/org/repo
like image 41
Stéphane Bruckert Avatar answered Nov 12 '22 03:11

Stéphane Bruckert