Go Tutorial Index

Before using Go programming, you must install it in your system and set up an environment to start working on it. This tutorial will give you a quick walkthrough of installing Go and setting up a development environment. Go installation is a simple process, just like other software installations. Go setup is available for Windows, Linux, and MAC operating systems. You can follow the steps given below to install Go on your OS.

Quickly download and install GO on your OS from (https://go.dev/) the official website of GO.

Install Go on Windows OS

  1. Download the MSI file from the official website of Go.
  2. Once the MSI file is downloaded, open it to start the installer.
  3. Follow the installation wizard till the end.
  4. Once the Go gets installed on your system, you can check whether it is properly installed or not. Open CMD and type the command:
    go version

    You are good to go if it shows the version number of the installed software.

  5. Also, check if your GOPATH is set up correctly or not.
  6. Go to Control Panel --> Systems and Security --> Systems --> Advanced system settings (from the left window pane) --> Environment Variable.
  7. Check whether GOPATH is set or not. Here you can see GOPATH is set to %USERPROFILE%\go.

Install Go on Linux OS

Go can be easily setup from the terminal using just a few commands.

  1. Download the installation tar.gz package file from the official website.
  2. Once downloaded, you need to move and unzip it to the local directory. For this, the command would be:
    tar -C /usr/local -xzf go1.15.6.linux-amd64.tar.gz

    In my system, the command looks something like this:

    tar -C /usr/local -xzf /mnt/c/Users/karlos/Downloads/go1.15.6.linux-amd64.tar.gz
  3. Now, to Setup the PATH environment variable, you need to open the .bashrc or .bash_profile file using the command in the terminal:
    vim ~/.bash_profile
  4. Next, you have to append the following path to the new line of the file.
    export PATH=$PATH:/usr/local/go/bin
  5. You must add the GOPATH to your environment variable. In that .bash_profile file, you have to append a new variable called $GOPATH to set the location where the Golang apps will remain live.
    export GOPATH="/mnt/c/Users/${yourusername}/directory/to/your/golang/workplace"
  6. Test whether your Go is running correctly or not.
    source ~/.bash_profile
  7. Exit the file and then go to the terminal again.
  8. Type the command: go version If you see it's showing the version of Go you have installed, your setup is ready.

Install Go on MAC OS

  1. Download the installation package file from the official website.
  2. Run the installer package by following the installation wizard.
  3. Once the installation is complete, verify whether the installation works successfully or not, and for that, you need to open Mac Terminal and run the following command:
    go version

    If it shows the version name, you are good to go.

  4. Next, you must create a folder under " Go " in the documents directory. Then, open the terminal and navigate to your home directory using the command:
    cd ~
  5. Now, you have to set the path of the folder by appending the line to the .bash_profile through the command:
    echo "export GOPATH = /Users/karlos/Documents/go" >> .bash_profile
  6. You can check whether the .bash_profile contains the path or not using the command:
    cat .bash_profile
    echo $GOPATH
  7. If you see your desired path showing, you are good to start programming.