Unable to build protobuf to go endpoint

后端 未结 12 784
日久生厌
日久生厌 2021-01-30 12:39

using protobuf version 2.6.1 ( which i installed via homebrew)

I am trying to run

$ protoc --go_out=../cloud/ *.proto

I keep receiv

相关标签:
12条回答
  • 2021-01-30 13:09

    If you're using Fedora, ensure that the package "protoc-gen-go" is installed, and it's binary is in your shel PATH.

    $sudo dnf install protoc-gen-go -y

    0 讨论(0)
  • 2021-01-30 13:11

    What I did to solve this was:

    copy protoc-gen-go from the go bin folder in go workspace to /usr/local/bin/

    run your command as before in your case "protoc --go_out=../cloud/ *.proto"

    0 讨论(0)
  • 2021-01-30 13:14

    On Ubuntu 18.04, this is verified working to solve this issue:

    sudo apt-get install golang-goprotobuf-dev

    0 讨论(0)
  • 2021-01-30 13:16

    How I solved:

    1. Add $GOPATH/bin to PATH by running export PATH=$PATH:$GOPATH/bin
    2. add export GOPATH=$(go env GOPATH) above export PATH=$PATH:$GOPATH/bin line inside the .bash_profile file.
    3. run go get -u for the required packages again.
    4. run the code protoc --go_out=../cloud/ *.proto in your case.
    0 讨论(0)
  • 2021-01-30 13:18

    Using

    $ go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
    

    is more safe than using

    $ sudo apt-get install golang-goprotobuf-dev
    

    Because the latest protoc-gen-go is using the lib github.com/golang/protobuf/proto, but protoc-gen-go in apt-get using the lib code.google.com/p/goprotobuf/proto which didn't exist now.

    0 讨论(0)
  • 2021-01-30 13:19

    Ensure that your path to proton-gen-go in your PATH variable is absolute (i.e. /Users/me/go/bin instead of ~/go/bin.

    Apparently protoc does not know how to expand ~.

    0 讨论(0)
提交回复
热议问题