DEV Community

loading...
Cover image for How to install 'Go' on Linux

How to install 'Go' on Linux

Edison Ade
I like doing, helping people do, getting things done. founder. http://codewit.co . directorat http://loudspeakerdigital.com lead. http://bloopglobal.com , http://agriprohub.com , souledoutlive.
・2 min read

  1. Check to see that your packages are up to date in the terminal type sudo apt-get update This will bring in all the repo list and update them. It will also tell you how many of the packages can be upgraded Now we are getting ready to install go
  2. Go to the Go website and download the linux package. https://golang.org/

  3. Create the folder usr and inside that the folder another folder called local.
    Extract downloaded file to usr/local.
    If you CD to usr/local/go and type go version you can see go version is installed.

But we want to be able to use go from everywhere on our computer.
To do that we need to set the path in our Vim profile or your preferred editor.

  1. Type Vim ~/.profile and then add to path
    PATH = $PATH: /usr/local/go/bin
    Save and close!

  2. Type go version anywhere on the terminal. You should see the version of go you installed displayed on your screen.
    Hurray now you have go installed.

  3. Let us create our first file for testing purposes.
    Type what you see below

    *CD /tmp *
    Then create a new file.
    *Vim test.go *
    Type what you see below inside the test.go file you just created.

    Package main
    Import 'fmt'
    Func main () {
    Fmt.println("Welcome to my first go code!")
    }

  4. Save the file and close it then run it.
    type what you see below to run it
    ** Go run test.go **
    You should see the result Welcome to my first go code! displayed.

Congratulations!.

Side note


I am taking up the challenge to learn Go in 100 days. Will share from time to time what the journey is like. Want to build an application at the end of the 100 days. Please share your experience with Go and resources you have so we can cross reference etc.

Discussion (0)