Skip to content

Instantly share code, notes, and snippets.

@d2s
Last active May 10, 2023 22:45
Show Gist options
  • Star 26 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save d2s/6503f815431d1587c28bc37bfd715dbf to your computer and use it in GitHub Desktop.
Save d2s/6503f815431d1587c28bc37bfd715dbf to your computer and use it in GitHub Desktop.
Installing Go with command line

NOTE: This is heavily outdated Gist snippet from 2017.


Install Go language with a Bash script

Another alternative to installing Go is to use a simple Bash script. It will download and install Go language under of your own user account.

Note that a system-wide installation might be better for some things (for example, better protected from accidental modifications etc.), but this was a bit simpler to setup.

For this example, we are using:

Create directory

mkdir -p ~/git/GitHub/canha

Clone Git repository

cd ~/git/GitHub/canha
git clone https://github.com/canha/golang-tools-install-script 
cd golang-tools-install-script/

Install a 64-bit version

bash goinstall.sh --64

Script downloads the version specified in the Bash script (at the moment 1.9.2) and installs it to ~/.go directory.

Check that it was added to your shell config

cat ~/.bashrc

Reload your shell

source ~/.bashrc

Try if it works

go help

That should show a quick help for the go command.

Installing Go to Ubuntu Linux

Install gvm

Install required packages for gvm

sudo apt-get install curl git mercurial make binutils bison gcc build-essential

Install old Go version first

gvm install go1.4 -B
gvm use go1.4
export GOROOT_BOOTSTRAP=$GOROOT

Look what is the latest Go version

Now after installing the old version, look for the latest release.

  • Open URL https://golang.org/dl/ and look what is the latest version number.
  • Then look if that release is available via gvm:
    • gvm listall
  • Install latest version
    • gvm install go1.8.3
  • Set it as the default version:
    • gvm use go1.8.3 --default

Updating to a new version

If you have previous version of Go already installed, you can update to a new release version of Go with these steps:

  • gvm install go1.8.3
  • gvm use go1.8.3 --default
@LIP17
Copy link

LIP17 commented Aug 2, 2017

It is useful, thank you!

@natrod
Copy link

natrod commented Dec 11, 2017

This is exactly what i was looking for thanks :)

@Sanix-Darker
Copy link

sudo apt-get install golang works for me as well !
Am on Ubuntu !

@d2s
Copy link
Author

d2s commented Dec 17, 2019

@Sanix-Darker, agreed, this snippet is from 2017 and would most likely do things differently these days.

@giacomovalenti
Copy link

Not working anymore ARMv7 binaries no longer available on storage.googleapis.com

@d2s
Copy link
Author

d2s commented Apr 5, 2020

Yeah, this Gist is last modified on Dec 29, 2017.

@therealnoobnoob01
Copy link

give us a kali linux 2020.1 install guid

@FatalSerpent
Copy link

This installed on kali linux 2020.3 great work i have looked for a way to do this and you are the only tutorial that helped me get this installed. Thank you.

@dolmen
Copy link

dolmen commented Sep 16, 2022

See also: https://github.com/dolmen-go/upgrade-golang for Linux environments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment