protoc-gen-go: program not found or is not executable

前端 未结 6 1472
逝去的感伤
逝去的感伤 2021-01-02 03:34

I am trying to build a sample app with go grpc but I am unable to generate the code using \"protoc\"

Have installed the required libraries/go packages using:

6条回答
  •  独厮守ぢ
    2021-01-02 04:10

    There are two ways to install the protobuf compiler, if you're on Ubuntu you can use this,

    sudo apt install protobuf-compiler
    

    Then of course there's the standard way,

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

    Here forward it's just adding the path. Assuming when you installed Go you did this,

    echo 'export GOPATH=$HOME/Go' >> $HOME/.bashrc
    source $HOME/.bashrc
    

    Now you can just extend this,

    echo 'export PATH=$PATH:$GOPATH/bin' >> $HOME/.bashrc
    source $HOME/.bashrc
    

    Strangely protoc can't expand ~.

提交回复
热议问题