Go Lesson 2 – installing go and-setup | Dataplexa

Installing Go & Environment Setup

Before writing real Go applications, you must install the Go programming language and configure your system correctly. In this lesson, you will learn how to install Go on Windows, macOS, and Linux, and verify that everything works.


Why Proper Setup Matters

A correct Go setup ensures:

  • Programs compile without errors
  • Packages and modules work correctly
  • Go tools like go run and go build function properly

Even small mistakes during installation can cause issues later, so follow the steps carefully.


Step 1: Download Go

Go is officially distributed by the Go team. Always download it from the official website to ensure security and compatibility.

Choose the installer that matches your operating system:

  • Windows (.msi)
  • macOS (.pkg)
  • Linux (.tar.gz)

Step 2: Install Go on Your System

Windows Installation

Run the downloaded .msi installer and follow the on-screen instructions. Go is usually installed in:

C:\Program Files\Go

macOS Installation

Open the .pkg file and complete the installation wizard. Go will be installed in:

/usr/local/go

Linux Installation

Extract the archive and move it to /usr/local:

sudo tar -C /usr/local -xzf go1.xx.x.linux-amd64.tar.gz

Step 3: Verify Go Installation

After installation, open a terminal or command prompt and run:

go version

If Go is installed correctly, you will see output similar to:

go version go1.22.0 windows/amd64

Understanding Go Environment Variables

Go uses environment variables to manage paths and modules. The most important ones are:

  • GOROOT – where Go is installed
  • GOPATH – workspace for your projects
  • PATH – allows running Go commands globally

Modern Go versions configure most of this automatically, so manual setup is rarely required.


Running Your First Test Command

Create a new folder and run:

go env

This command displays all Go environment values and confirms everything is configured.


Common Installation Issues

  • Command not found: Go is not added to PATH
  • Wrong version: Old Go installation still exists
  • Permission errors: Missing admin/sudo privileges

Reinstalling Go from the official website fixes most issues.


Practice Exercise

Exercise

Install Go on your system and verify the installation by running go version.

Expected Output

go version go1.xx.x your-os/architecture

What’s Next?

In the next lesson, you will learn about the Go workspace, project structure, and how Go organizes code using packages and modules.