Skip to content

Instantly share code, notes, and snippets.

@plar
Created January 20, 2016 21:00
Show Gist options
  • Select an option

  • Save plar/4eec521bf5ac9ed4daa1 to your computer and use it in GitHub Desktop.

Select an option

Save plar/4eec521bf5ac9ed4daa1 to your computer and use it in GitHub Desktop.

Revisions

  1. plar created this gist Jan 20, 2016.
    26 changes: 26 additions & 0 deletions golang.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    #!/bin/bash

    export GOLANG_VERSION=1.5.3
    export GOLANG_DOWNLOAD_URL=https://storage.googleapis.com/golang/go$GOLANG_VERSION.linux-amd64.tar.gz
    export GOLANG_DOWNLOAD_SHA256=43afe0c5017e502630b1aea4d44b8a7f059bf60d7f29dfd58db454d4e4e0ae53

    apt-get update -qq

    apt-get install -y --no-install-recommends \
    g++ \
    gcc \
    libc6-dev \
    make \
    git-core

    curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \
    && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \
    && tar -C /usr/local -xzf golang.tar.gz \
    && rm golang.tar.gz

    for bin in $(ls /usr/local/go/bin/); do
    test -f /usr/bin/$bin && rm /usr/bin/$bin
    update-alternatives --install /usr/bin/$bin $bin /usr/local/go/bin/$bin 1
    update-alternatives --set $bin /usr/local/go/bin/$bin
    done