-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Description
#40276 implements go install path@version
for installing a Go binary outside a module. I propose the same support added to go run
, with equivalent behavior. That is,
$ go run gioui.org/cmd/gogio@d5bdf0756a5a
should build and run the gioui.org/cmd/gogio
program at version d5bdf0756a5a
Why isn't go install
enough for my uses? Consider a README describing how to build and use an auxiliary Go program:
To build the XYZ Android app you need to use the
gogio
tool:$ export PATH=$PATH:$GOPATH/bin
$ go install gioui.org/cmd/gogio@d5bdf0756a5a
$ gogio -target android example.com/cmd/xyz
The README has several issues:
go install
'ing the binary is reproducible, but running it isn't. For example, the user may have an oldgogio
in their PATH already, and fail to run the instructedgo install
. They may remember, but later install a different version ofgogio
.go install
polutes the user's GOPATH/bin, and PATH if it includes GOPATH/bin.- If GOPATH is not set, the README has to contain hardcoded paths (~/go/bin).
In contrast, with go run path@version
support, the README is reduced to just:
To build the XYZ Android app you need to use the
gogio
tool:$ go run gioui.org/cmd/gogio@d5bdf0756a5a -target android example.com/cmd/xyz