Skip to content

Instantly share code, notes, and snippets.

@alecthegeek
Last active July 30, 2017 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alecthegeek/c09cc8df1ccae8525517bf66530a785d to your computer and use it in GitHub Desktop.
Save alecthegeek/c09cc8df1ccae8525517bf66530a785d to your computer and use it in GitHub Desktop.
Installing Go (via Go Version Manager), Go tools and Vim Go
# Install GVM following instructions at https://github.com/moovweb/gvm
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
if [[ ! -s "$HOME/.gvm/scripts/gvm" ]] ; then
Go Version Manager is not installed -- please see https://github.com/moovweb/gvm
exit 1
fi
source "$HOME/.gvm/scripts/gvm" # Need acccess to gvm() in current process
# Now install the latest Go version
LATEST_VERSION=$(gvm listall | sed -Ene '/^[ \tab]*(go[0-9]+\.[0-9]+((\.[0-9])?))$/s//\1/p' |tail -1) #edit \tab
gvm install "$LATEST_VERSION"
gvm use "$LATEST_VERSION" --default
# Now install some tool into the $GOROOT/bin
GOPATH=/tmp GOBIN=$(go env GOROOT)/bin go get -u golang.org/x/tools/cmd/...
GOPATH=/tmp GOBIN=$(go env GOROOT)/bin go get -u github.com/tools/godep
GOPATH=/tmp GOBIN=$(go env GOROOT)/bin go get -u github.com/nsf/gocode
GOPATH=/tmp GOBIN=$(go env GOROOT)/bin go get -u github.com/constabulary/gb/...
GOPATH=/tmp GOBIN=$(go env GOROOT)/bin go get -u github.com/golang/lint/golint/...
GOPATH=/tmp GOBIN=$(go env GOROOT)/bin go get -u github.com/rogpeppe/godef
GOPATH=/tmp GOBIN=$(go env GOROOT)/bin go get -u github.com/ramya-rao-a/go-outline
GOPATH=/tmp GOBIN=$(go env GOROOT)/bin go get -u github.com/tpng/gopkgs
GOPATH=/tmp GOBIN=$(go env GOROOT)/bin go get -u sourcegraph.com/sqs/goreturns
# Now install the tools needed for Vim Go into $GOROOT/bin
git clone https://github.com/fatih/vim-go.git ~/.vim/pack/tools/start/vim-go
GOPATH=/tmp GOBIN=$(go env GOROOT)/bin vim -c ":GoInstallBinaries" -c ":qall" /tmp/src/$$.go
# and to upgrade the same thing
GOPATH=/tmp GOBIN=$(go env GOROOT)/bin vim -c ":GoUpdateBinaries" -c ":qall" /tmp/src/$$.go
#!/usr/bin/env bash
if [[ ! -s "$HOME/.gvm/scripts/gvm" ]] ; then
Go Version Manager is not installed -- please see https://github.com/moovweb/gvm
exit 1
fi
source "$HOME/.gvm/scripts/gvm" # Need acccess to gvm() in current process
LATEST_VERSION=$(gvm listall | sed -Ene '/^[ \tab]*(go[0-9]+\.[0-9]+((\.[0-9])?))$/s//\1/p' |tail -1) #edit \tab
echo Lookng for version $LATEST_VERSION
gvm install "$LATEST_VERSION" # Will check if it's already installed
gvm use "$LATEST_VERSION" --default # Is a function so do not need eval
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment