Wayne Werner
Wayne Werner

Reputation: 51867

What's the proper way to install a go package to the system path?

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?

I'm not using any of the pre-built packages because none exist for Raspbian Jesse.

Upvotes: 1

Views: 212

Answers (2)

Wayne Werner
Wayne Werner

Reputation: 51867

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.

Upvotes: 0

Roeften
Roeften

Reputation: 434

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

Upvotes: 0

Related Questions