Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: install package for all users #33234

iptaylortechnical opened this issue Jul 22, 2019 · 4 comments

cmd/go: install package for all users #33234

iptaylortechnical opened this issue Jul 22, 2019 · 4 comments


Copy link

@iptaylortechnical iptaylortechnical commented Jul 22, 2019

Global go get

As it is, go get installs to $GOPATH/src, traditionally /home/$USER/go/src. Unfortunately, this means that modules cannot be installed for all users, unless everyone shares a $GOPATH (and all have access to that directory). This would be very unconventional for Linux.

Since there is already a global $GOROOT/src, there should be an option to go get packages to that location, making them available for all users.

Use cases:

  • sysadmins who want to add a tool to the environment available for everyone
  • machines with multiple users for multiple functions can share packages

Add a global flag to go get (e.g. go get -g) that installs to $GOROOT instead of $GOPATH.


This comment has been minimized.

Copy link

@AlexRouSg AlexRouSg commented Jul 22, 2019

Do you only care about the executable or do you want the sources to be global too?

There is a GOBIN variable that lets you set where to put the executables.

If you want the sources to be global, you can have multiple GOPATH directories e.g. GOPATH=/some/global/path:/home/$USER/go and go get should download to the first path, but build should search all paths. I'm not sure if this works in module mode tho.


This comment has been minimized.

Copy link

@agnivade agnivade commented Jul 23, 2019

In module mode, if you are running a go get outside a module, then the binary will be installed in GOBIN. So then, your binary becomes available for all users. But if you are talking about running a global install inside a module then #30515 is for that.

Regarding sharing packages, I believe it will take us back to GOPATH mode from module mode. Each module will always have it's own go.mod which will pin down it's version. Having a global package will break this as the version of the global package and in go.mod can go out of sync.

@ALTree ALTree added this to the Unplanned milestone Jul 23, 2019
@ALTree ALTree changed the title cmd/go feature request: Install package for all users cmd/go: install package for all users Jul 23, 2019

This comment has been minimized.

Copy link

@bcmills bcmills commented Jul 25, 2019

The functionality you propose seems like it would overlap significantly with GOPROXY. In particular, a GOPROXY setting using a file:// URL can easily point to a shared read-only directory tree, from which individual users can go get files into their local GOPATH cache.

Do you have any particular use-cases in mind that cannot be satisfied using a combination of GOPROXY (to retrieve modules from the shared cache) and GOPATH + go mod download (to populate modules into the shared cache)?


This comment has been minimized.

Copy link

@gopherbot gopherbot commented Aug 25, 2019

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@gopherbot gopherbot closed this Aug 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
6 participants
You can’t perform that action at this time.