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
- Download the MSI file from the official website of Go.
- Once the MSI file is downloaded, open it to start the installer.
- Follow the installation wizard till the end.
- Once the Go gets installed on your system, you can check whether it is correctly installed or not. Open CMD and type the command:
D:\>go version go version go1.19.3 windows/amd64
You are good to go if it shows the version number of the installed software.
- Also, check if your GOPATH is set up correctly or not.
- Go to Control Panel --> Systems and Security --> Systems --> Advanced system settings (from the left window pane) --> Environment Variable.
- 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.
- Download the installation tar.gz package file from the official website.
- 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
- Now, to Setup the PATH environment variable, you need to open the .bashrc or .bash_profile file using the command in the terminal:
- Next, you have to append the following path to the new line of the file.
- 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.
- Test whether your Go is running correctly or not.
- Exit the file and then go to the terminal again.
- Type the command:
go versionIf you see it's showing the version of Go you have installed, your setup is ready.
Install Go on MAC OS
- Download the installation package file from the official website.
- Run the installer package by following the installation wizard.
- 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:
If it shows the version name, you are good to go.
- 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:
- 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
- You can check whether the .bash_profile contains the path or not using the command:
cat .bash_profile echo $GOPATH
- If you see your desired path showing, you are good to start programming.