To install Go (Golang) on a Linux system, you can follow these steps:
-
Download Go: Open a terminal window and use the
wget
command to download the Go installation package. You can find the latest version of Go on the official Golang download page.
For example, to download Go version 1.17, you can use:
wget https://golang.org/dl/go1.17.linux-amd64.tar.gz
-
Extract the Archive: After downloading, you need to extract the downloaded archive. Use the
tar
command to extract it:
tar -xvf go1.17.linux-amd64.tar.gz
-
Move Go: Move the extracted Go directory to a location on your system. Traditionally, it's placed in the
/usr/local
directory. You'll need superuser (root) privileges for this:
sudo mv go /usr/local
-
Set Environment Variables: You need to set some environment variables to let your system know where Go is installed and where your Go workspace (where you'll develop your Go programs) is located. Add the following lines to your shell profile configuration file (e.g.,
~/.bashrc
,~/.zshrc
, or~/.profile
):
export GOPATH=$HOME/go
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin
Then, apply the changes to your current shell session:
source ~/.zshrc ~/.bashrc # or the appropriate configuration file
- Verify Installation: You can now verify that Go is installed correctly by opening a new terminal window and typing:
go version
go1.17 linux/amd64
You should see the installed Go version printed in the output.
Top comments (0)