Skip to content

Instantly share code, notes, and snippets.

@codevulture
Created January 19, 2017 05:09
Show Gist options
  • Save codevulture/03e7b9f8aff29aa80defddbb65a2c18e to your computer and use it in GitHub Desktop.
Save codevulture/03e7b9f8aff29aa80defddbb65a2c18e to your computer and use it in GitHub Desktop.
#!/bin/sh
GITHUB_USER=codevulture
#Download Compatible version of Go
GO_VERSION=go1.7.4.linux-amd64.tar.gz
VM_USER=vagrant
wget https://storage.googleapis.com/golang/$GO_VERSION > /dev/null 2>&1
sudo tar -C /usr/local -xzf $GO_VERSION
#Add to bash if needed
#set environment variables for Go
su "$VM_USER" -c "echo 'source /vagrant/go_rc' >> ~/.bashrc"
#Set go directory and go paths
su $VM_USER
mkdir $HOME/work
mkdir -p $GOPATH/src/github.com/$GITHUB_USER
mkdir $GOPATH/src/github.com/$GITHUB_USER/hello
cat > hello.go << EOF
package main
import "fmt"
func main() {
fmt.Printf("Hello, world.\n")
}
EOF
scp -r hello.go $GOPATH/src/github.com/$GITHUB_USER/hello/
go install github.com/$GITHUB_USER/hello
$GOPATH/bin/hello
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/work
export PATH=$PATH:$GOPATH/bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment