简体   繁体   English

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

[英]How do I properly install protoc-gen-go on Ubuntu?

I managed to download and install Go on Ubuntu.我设法在 Ubuntu 上下载并安装了 Go。 However, I'm currently unable to set up protoc-gen-go properly because my GOPATH and GOROOT are not properly defined.但是,我目前无法正确设置 protoc-gen-go,因为我的 GOPATH 和 GOROOT 没有正确定义。 Here's what my GOROOT and GOPATH look like:这是我的 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

Try to remove all of these lines, and replace them with:尝试删除所有这些行,并将它们替换为:

#export GOROOT=/usr/local/go # this should not be needed
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT:$GOPATH:$GOBIN

No need to export PATH so many times..不需要多次导出PATH..

Also using ~ in export GO_PATH=~/go can cause issues.export GO_PATH=~/go中使用~也会导致问题。

Once you add the lines to .bashrc reload your terminal, or execute these same lines in the terminal, so they take effect.将这些行添加到.bashrc后,重新加载终端,或在终端中执行这些相同的行,以便它们生效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM