curl -Ls http://bit.ly/go_installer | bash
If you want to install golang, normally you are following the description on the official dowload page
There is a WIP tool for installing golang in a machine/os independent way called getgo. Source is available on github
There is github issue describint the rational, and work behind the one-liner install. The README.md advices the following (works for linux/osx/windows):
curl -LO https://get.golang.org/$(uname)/go_installer && chmod +x go_installer && ./go_installer && rm go_installer
But if you check the server logic you can see, that it only checks if the url is matched containsIgnoreCase agains MINGW/Linux/Darwin. So the url can be just:
https://get.golang.org/$(uname)
. Curl can follow redirects, so curl -Lo installer get.golang.org/linux
So for cloud servers and/or docker containers you can do:
curl -Lo go_installer https://get.golang.org/linux && chmod +x go_installer && ./go_installer && rm go_installer
curl -Ls http://bit.ly/go_installer | bash
The one-liner is capable of doing the following steps (also interactively):
- chooseVersion
- downloadGo
- unzip
- setupGOPATH
If you want only the download part, on linux it would be :
VERSION=go1.9.3
curl -L https://dl.google.com/go/go1.9.3.linux-amd64.tar.gz | tar -xz -C /usr/local
# old url
# curl -L https://storage.googleapis.com/golang/$VERSION.linux-amd64.tar.gz
The binary linux distribution is normally dynamically lnked to glibc. It menas that the all above will fail on alpine. There are 2 workarounds:
- Use
frolvlad/alpine-glibc
instead oflibrary/alpine
as a base image - Download the releavant docker image layer from golang:alpine : code here
- The announcement at golang-nuts
- The download url was changed in a recent commit