将Go包正确安装到系统路径的方法是什么?

huangapple go评论91阅读模式
英文:

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=&quot;$PATH:/usr/local/go/bin&quot; GOPATH=/usr/local/go/ go get github.com/keybase/client/go/keybase
PATH=&quot;$PATH:/usr/local/go/bin&quot; 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.

huangapple
  • 本文由 发表于 2017年1月11日 01:15:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/41574521.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定