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:
- Run the downloaded MSI file.
- Follow the prompts in the installation wizard.
- By default, Go will be installed in
C:\Go
. - 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:
- Run the downloaded PKG file.
- Follow the instructions in the installation wizard.
- By default, Go will be installed in
/usr/local/go
.
- Open your terminal.
- Run the command
brew install go
.
Installing Go on Linux
To install Go on Linux, you can use the tarball:
- Download the tarball using
wget
orcurl
. - Extract the tarball to
/usr/local
using the command:sudo tar -C /usr/local -xzf go1.xx.x.linux-amd64.tar.gz
, replacing1.xx.x
with the current version. - 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.
Basics
- Previous
- Introduction
- Next
- Running Code