Last active
July 30, 2017 00:27
-
-
Save alecthegeek/c09cc8df1ccae8525517bf66530a785d to your computer and use it in GitHub Desktop.
Installing Go (via Go Version Manager), Go tools and Vim Go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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