英文:
What's the proper way to install a go package to the system path?
问题
我正在尝试安装一个go
项目(特别是keybase客户端),但我想要将其全局安装到系统上的所有用户。
我搜索了一下,发现有一些人不小心将东西安装到了/usr/local/go/bin
或类似的位置,但没有关于如何正确安装到这些位置的说明。
但这正是我想要做的-全局安装应用程序。我应该如何使用go进行安装?
我没有使用任何预构建的软件包,因为Raspbian Jesse上没有这样的软件包。
英文:
I'm trying to install a go
project (the keybase client, in particular), but I want to install it globally for all the users on my system.
I've searched around and found a few people who accidentally install things to /usr/local/go/bin
or something to that effect, but no instructions on how I actually should be installing things to such locations.
But that's what I want to do - globally install the application. How should I be doing that with go?
<sub><sup>I'm not using any of the pre-built packages because none exist for Raspbian Jesse</sup></sub>.
答案1
得分: 0
你是否尝试设置$GOBIN,例如:
GOBIN=/usr/local/bin/ 或 GOBIN=/usr/bin/ 或者PATH中的任何目录?
然后执行:
export GOBIN
然后安装应用程序?
根据手册,$GOBIN的默认值是$GOROOT/bin,所以我猜这些用户将GOROOT设置为/usr/local/go。
英文:
Have you tried setting $GOBIN like:
GOBIN=/usr/local/bin/ or GOBIN=/usr/bin/ or any directory in the PATH?
and then:
export GOBIN
and then install the app?
According to the manual the default $GOBIN is $GOROOT/bin so I guess those users set GOROOT to /usr/local/go
答案2
得分: 0
我采取的方法是这样的:
PATH="$PATH:/usr/local/go/bin" GOPATH=/usr/local/go/ go get github.com/keybase/client/go/keybase
PATH="$PATH:/usr/local/go/bin" GOPATH=/usr/local/go/ go install -tags production github.com/keybase/client/go/keybase
这将把 keybase
安装到 /usr/local/go/bin/keybase
。可能还有更好的方法,但目前我还没有找到。
英文:
The approach that I've taken is this:
PATH="$PATH:/usr/local/go/bin" GOPATH=/usr/local/go/ go get github.com/keybase/client/go/keybase
PATH="$PATH:/usr/local/go/bin" GOPATH=/usr/local/go/ go install -tags production github.com/keybase/client/go/keybase
Which ends out installing keybase
to /usr/local/go/bin/keybase
. It's possible that there's a better way, but so far I haven't seen one.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论