Skip to content

Instantly share code, notes, and snippets.

@jpillora
Last active July 28, 2022 06:38
Show Gist options
  • Save jpillora/dcabf16e99d087eae6e0 to your computer and use it in GitHub Desktop.
Save jpillora/dcabf16e99d087eae6e0 to your computer and use it in GitHub Desktop.

Revisions

  1. jpillora revised this gist Oct 29, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install-go.sh
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ fi
    function install {

    echo "Fetching latest Go version..."
    typeset VER=`curl -s http://golang.org/dl/ | grep -m 1 -o 'go1\(\.[0-9]\)\+'`
    typeset VER=`curl -s https://golang.org/dl/ | grep -m 1 -o 'go1\(\.[0-9]\)\+'`
    if uname -m | grep 64 > /dev/null; then
    typeset ARCH=amd64
    else
  2. jpillora created this gist Sep 4, 2014.
    37 changes: 37 additions & 0 deletions install-go.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    #!/bin/bash

    #force run with bash
    if [ -z "$BASH_VERSION" ]
    then
    exec bash "$0" "$@"
    return
    fi

    #create local scope
    function install {

    echo "Fetching latest Go version..."
    typeset VER=`curl -s http://golang.org/dl/ | grep -m 1 -o 'go1\(\.[0-9]\)\+'`
    if uname -m | grep 64 > /dev/null; then
    typeset ARCH=amd64
    else
    typeset ARCH=386
    fi
    typeset FILE=$VER.linux-$ARCH
    echo "Installing '$FILE'..."

    curl -# https://storage.googleapis.com/golang/$FILE.tar.gz |
    tar -C /usr/local -xzf -

    echo "
    # Go Paths (Added on: `date -u`)
    export GOPATH=\$HOME/go
    export PATH=\$PATH:/usr/local/go/bin:\$GOPATH/bin
    " >> ~/.bash_profile

    . ~/.bash_profile

    echo "Go is installed and your GOPATH is '$HOME/go'"
    echo "Please reload this shell or enter the command '. ~/.bash_profile'"
    }
    install