Want to learn how to build better Go applications faster and easier? You can.
Check out my course on the Go Standard Library. You can check it out now for free.
If you want to install Go on Ubuntu, it’s very easy.
tar -xvf go1.x.x.linux-amd64.tar.gz
Replace x.x with the actual version number of Go.
/usr/local
, so all users on the system can use Go.sudo mv go /usr/local
~/.profile
file and add the following line at the end:export PATH=$PATH:/usr/local/go/bin
source ~/.profile
go version
This should print the installed version of Go.
You may also want to set up your Go workspace by defining the GOPATH
environment variable. The GOPATH variable specifies the location of your Go workspace, where your Go source code and libraries are stored.
By default, the go command will look for packages in the $GOPATH/src
directory and will store the compiled binaries in the $GOPATH/bin directory.
To set the GOPATH variable, open your ~/.profile
file and add this line:
export GOPATH=$HOME/go
Replace $HOME/go with the desired location of your Go workspace.
Don’t forget to reload the ~/.profile file to apply the changes:
source ~/.profile
That’s it! You now have Go installed on your Ubuntu system.