Install Go and check the version

Contents
Install on Linux
go version
GOPATH and PATH
Keep it updated

Install on Linux

Before writing code, set up the toolchain once using the detailed guide install Go on Linux.

In short: unpack the release archive into /usr/local, add /usr/local/go/bin to PATH, and create a working folder for projects.

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

export PATH=$PATH:/usr/local/go/bin

The second command extends PATH for the current shell only, so add the same line to the shell profile to keep it permanent.

go version

A fresh install should answer with its version number.

go version

go version go1.21 linux/amd64

If the command is not found, recheck PATH from the previous section and open a new terminal window.

GOPATH and PATH

PATH tells the shell where to find the go binary, while GOPATH points to the workspace with downloaded modules and helper binaries.

Modern Go works in any folder, so beginners can accept the defaults and inspect them only when something looks wrong.

go env GOPATH

/home/user/go

go env GOROOT

/usr/local/go

Keep it updated

To upgrade, remove the old installation tree, unpack the new archive into the same place, and verify the version again.

sudo rm -rf /usr/local/go

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

go version

go version go1.21 linux/amd64

Next: Your first Go program

Article author: Arthur Isaev

Related articles
Golang
Go course: zero to hero in 50 lessons
What is Go and where it runs
Install Go and check the version
Your first Go program
Modules with go mod
Variables
Constants
Types
Numbers
Strings
Conditions with if
Switch in Go
Loops with for
Arrays in Go
Slices in Go
Maps in Go
Functions in Go
Errors as values
Pointers in Go
Structs in Go
Methods in Go
Interfaces in Go
Embedding instead of inheritance
Generics in Go
Packages and imports
The go toolchain
Testing with go test
Advanced errors
defer in Go
Strings, bytes and runes
Time in Go
JSON
Files and IO
HTTP servers
HTTP clients
Context
Goroutines
Channels
select and sync
CLI: args, flags, env
Logging
Regular expressions
Sorting
Concurrency patterns
Databases with database/sql
Benchmarks and profiling
Toolchain and CI
Project layout
Capstone: wordfreq CLI
Capstone: JSON API server
Hero roadmap: the whole course on one page
Install Go on Windows 11
Install Go on Ubuntu
Install Go on Rocky Linux
Install Go on macOS
Install Go on FreeBSD
Go in Docker
Banner image

Search this site

Channel @aofeed Chat @aofeedchat

Contacts and cooperation:
I recommend our hosting beget.ru
Write to info@urn.su if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: