github.com/blixtra/rkt@v0.8.1-0.20160204105720-ab0d1add1a43/scripts/install-go.sh (about)

     1  #!/bin/bash
     2  
     3  set -e
     4  
     5  export DEBIAN_FRONTEND=noninteractive
     6  VERSION=1.5.3
     7  OS=linux
     8  ARCH=amd64
     9  
    10  prefix=/usr/local
    11  
    12  which wget || apt-get install -y wget
    13  # not essential but go get depends on it
    14  which git || apt-get install -y git
    15  
    16  # grab go
    17  if ! [ -e "$prefix/go" ]; then
    18      if ! [ -e "go$VERSION.$OS-$ARCH.tar.gz" ]; then
    19          wget -q https://storage.googleapis.com/golang/go$VERSION.$OS-$ARCH.tar.gz
    20      fi
    21      tar -C $prefix -xzf go$VERSION.$OS-$ARCH.tar.gz
    22  fi
    23  
    24  # setup user environment variables
    25  if ! [ -e "/etc/profile.d/01go.sh" ]; then
    26      echo "export GOROOT=$prefix/go" | tee /etc/profile.d/01go.sh
    27  
    28      cat << 'EOF' | tee -a /etc/profile.d/go.sh
    29  
    30  export GOPATH=$HOME/.gopath
    31  
    32  [ -e $GOPATH ] || mkdir -p $GOPATH
    33  
    34  export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
    35  EOF
    36  
    37  fi