Skip to content

Instantly share code, notes, and snippets.

@roscopecoltran
Forked from rogpeppe/vgoget.sh
Created October 23, 2018 19:16
Show Gist options
  • Save roscopecoltran/0f3e0f8ef4f4b42c8b5bccc14d02a88b to your computer and use it in GitHub Desktop.
Save roscopecoltran/0f3e0f8ef4f4b42c8b5bccc14d02a88b to your computer and use it in GitHub Desktop.
go get binary@version
#!/bin/sh
# This command installs binaries at specified versions
# into $GOBIN, $GOPATH/bin or $HOME/bin.
# It assumes Go 1.11.
if [ $# = 0 ]; then
usage: vgoget cmdpackage[@version]... >&2
exit 2
fi
d=`mktemp -d`
cd "$d"
echo 'module temp' > go.mod
for i; do
pkg=`echo $i | sed 's/@.*//'`
go get "$i" &&
go install "$pkg" &&
echo installed `go list -f '{{.ImportPath}}@{{.Module.Version}}' "$pkg"`
done
rm -r "$d"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment