Basics

Go Installation

Installing Go

Go installation sets up the latest version with go command for development.

System Requirements

Before installing Go, ensure your system meets the following requirements:

  • Operating System: Windows, macOS, or Linux.
  • Architecture: x86-64 or ARM64.
  • Disk Space: At least 200 MB of free space.

Downloading Go

To download the latest version of Go, visit the official Go website at golang.org/dl/. Choose the appropriate installer for your operating system and architecture.

Installing Go on Windows

Once you have downloaded the installer, follow these steps to install Go on Windows:

  1. Run the downloaded MSI file.
  2. Follow the prompts in the installation wizard.
  3. By default, Go will be installed in C:\Go.
  4. Add C:\Go\bin to your system's PATH environment variable.

Installing Go on macOS

For macOS users, you can install Go using the PKG installer or with Homebrew.

Using the PKG installer:

  1. Run the downloaded PKG file.
  2. Follow the instructions in the installation wizard.
  3. By default, Go will be installed in /usr/local/go.
Using Homebrew:
  1. Open your terminal.
  2. Run the command brew install go.

Installing Go on Linux

To install Go on Linux, you can use the tarball:

  1. Download the tarball using wget or curl.
  2. Extract the tarball to /usr/local using the command: sudo tar -C /usr/local -xzf go1.xx.x.linux-amd64.tar.gz, replacing 1.xx.x with the current version.
  3. Add /usr/local/go/bin to your PATH variable by editing ~/.profile or ~/.bashrc.

Verifying Go Installation

After installation, verify it by opening a terminal and running the following command:

This command should output the installed version of Go, confirming that your installation was successful.

Setting Up Go Workspace

Once Go is installed, set up your workspace by creating a directory for your Go projects. By convention, this directory is named go and located in your home directory. Inside this directory, create three subdirectories: src, pkg, and bin. These will be used for source files, package objects, and compiled binaries, respectively.

Conclusion

You have successfully installed Go and set up your development environment. You can now begin creating Go programs and exploring the language further.