如何在Ubuntu上正确安装protoc-gen-go?

我设法在Ubuntu上下载并安装Go。但是,由于我的GOPATH和GOROOT定义不正确,我目前无法正确设置protoc-gen-go。这是我的GOROOT和GOPATH的样子:

export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT:$GOPATH:$GOBIN
export PATH="$PATH:$HOME/.local/bin"
export PATH=$PATH:$GOPATH/bin
export GO_PATH=~/go
export PATH=$PATH:/$GO_PATH/bin
评论
gquia
gquia

尝试删除所有这些行,并替换为:

export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT:$GOPATH:$GOBIN

无需多次导出PATH。

Also using ~ in export GO_PATH=~/go can cause issues.

Once you add the lines to .bashrc reload your terminal, or execute these same lines in the terminal, so they take effect.

点赞
评论