Skip to content

Instantly share code, notes, and snippets.

@SeanChristopherConway
Created August 31, 2020 19:00
Show Gist options
  • Select an option

  • Save SeanChristopherConway/5efe7f4427d72fb4618bf7903d23f4be to your computer and use it in GitHub Desktop.

Select an option

Save SeanChristopherConway/5efe7f4427d72fb4618bf7903d23f4be to your computer and use it in GitHub Desktop.

Revisions

  1. @besser besser revised this gist Jul 18, 2017. No changes.
  2. @besser besser created this gist Jul 17, 2017.
    44 changes: 44 additions & 0 deletions wsl-go-install.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    #!/bin/bash
    set -e

    GVERSION="1.8.3"
    GFILE="go$GVERSION.linux-amd64.tar.gz"

    GOPATH="$HOME/projects/go"
    GOROOT="/usr/local/go"
    if [ -d $GOROOT ]; then
    echo "Installation directories already exist $GOROOT"
    exit 1
    fi

    mkdir -p "$GOROOT"
    chmod 777 "$GOROOT"

    wget --no-verbose https://storage.googleapis.com/golang/$GFILE -O $TMPDIR/$GFILE
    if [ $? -ne 0 ]; then
    echo "Go download failed! Exiting."
    exit 1
    fi

    tar -C "/usr/local" -xzf $TMPDIR/$GFILE

    cp -f "$HOME/.bashrc" "$HOME/.bashrc.bkp"

    touch "$HOME/.bashrc"
    {
    echo ''
    echo '# GOLANG'
    echo 'export GOROOT='$GOROOT
    echo 'export GOPATH='$GOPATH
    echo 'export GOBIN=$GOPATH/bin'
    echo 'export PATH=$PATH:$GOROOT/bin:$GOBIN'
    echo ''
    } >> "$HOME/.bashrc"
    source "$HOME/.bashrc"
    echo "GOROOT set to $GOROOT"

    mkdir -p "$GOPATH" "$GOPATH/src" "$GOPATH/pkg" "$GOPATH/bin" "$GOPATH/out"
    chmod 777 "$GOPATH" "$GOPATH/src" "$GOPATH/pkg" "$GOPATH/bin" "$GOPATH/out"
    echo "GOPATH set to $GOPATH"

    rm -f $TMPDIR/$GFILE