You are currently viewing A Beginner’s Guide to Installing Go (Golang) on Your System

A Beginner’s Guide to Installing Go (Golang) on Your System

  • Post author:
  • Post category:Go
  • Post comments:0 Comments
  • Post last modified:May 15, 2024

Introduction to Installing Go (Golang)

Go, also known as Golang, is a powerful and efficient programming language developed by Google. To start programming in Go, you first need to install it on your system. In this tutorial, we’ll walk you through the steps of installing Go on various operating systems.

Prerequisites

Before you begin, ensure that you have administrative privileges on your system.

Installing Go on Windows

  1. Download Go Binary:
  1. Run Installer:
  • Double-click the downloaded .msi file to run the installer.
  • Follow the prompts in the installer, accepting the license agreement and choosing the installation directory.
  1. Set Environment Variables:
  • After installation, add Go’s bin directory to your system’s PATH variable. This step ensures that you can run Go commands from any terminal.
    bash setx /m PATH "%PATH%;C:\Go\bin"
  • Close and reopen any command prompts or terminals for the changes to take effect.
  1. Verify Installation:
  • Open a new command prompt and type the following command to verify that Go has been installed successfully:
    bash go version

Installing Go on macOS

  1. Install Homebrew (Optional):
  • If you have Homebrew installed, you can easily install Go using the following command:
    bash brew install go
  1. Download and Install Go Binary:
  • Alternatively, you can download the Go package for macOS from the official website.
  • Once downloaded, open the .pkg file and follow the installation instructions.
  1. Set Environment Variables:
  • After installation, add Go’s bin directory to your system’s PATH variable by adding the following line to your shell profile (e.g., .bashrc, .bash_profile, or .zshrc):
    bash export PATH=$PATH:/usr/local/go/bin
  • Reload your shell configuration or restart your terminal.
  1. Verify Installation:
  • Open a new terminal window and run the following command to verify that Go has been installed successfully:
    bash go version

Installing Go on Linux

  1. Download and Extract Go Binary:
  • Visit the official Go website and download the Linux tarball.
  • Extract the tarball to /usr/local or any other location of your choice:
    bash sudo tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
  1. Set Environment Variables:
  • Add Go’s bin directory to your PATH variable by appending the following line to your shell profile (e.g., .bashrc, .bash_profile, or .zshrc):
    bash export PATH=$PATH:/usr/local/go/bin
  • Reload your shell configuration or restart your terminal.
  1. Verify Installation:
  • Open a new terminal window and type the following command to verify that Go has been installed successfully:
    bash go version

Conclusion

Congratulations! You have successfully installed the Go programming language on your system. You’re now ready to start building powerful and efficient applications using Go.

Remember to refer to the official Go documentation and explore the vast ecosystem of libraries and tools available for Go development.

Leave a Reply