Go, an open source and modern programming language, created by Google that makes it easy to build simple and efficient software can easily be installed and used in Ubuntu. This brief tutorial shows students and new users how to install Go on Ubuntu 16.04 | 18.04 and 18.10.
Popular apps that include Kubernetes, Docker and Grafana and many others use Go. If you’re a serious developer who want to use this tool to build your apps, then continue below to learn how to install and use it in Ubuntu.To get started with installing Go, continue the steps below:
Step 1: Download Go Package
Go archive package is distributed by Google. At the time of this writing the current version is 1.11.1. You may have to change the version number to download the latest when it becomes available.
Run the commands below to download Go tarball archive package.
cd /tmp wget https://dl.google.com/go/go1.11.1.linux-amd64.tar.gz
After that, run th commands below to extract the downloaded package file into the system local directory.
sudo tar -xzvf go1.11.1.linux-amd64.tar.gz -C /usr/local/
That should extract Go content file to that destination folder making it available to the systems.
Step 2: Configure Go
Now that Go content folders are included into Ubuntu /usr/local directory. go and adjust the system environment variable to include Go executable directory.
In order to the system to know where to find Go executables, you must include that path in the system environment variable. This can be done system-wide or per profile basis.
System-wide environment change will make it available to other users using the system. If you have multiple users, then you should adjust the system-wide version.
To do that, run the commands below:
sudo nano /etc/environment
Then add the highlighted line below into the file. the file should look similar to the one below.
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/$ export PATH=$PATH:"/usr/local/go/bin"
Save the file and exit.
After that, run the commands below to make the change apply.
That should do it.
To test whether Go is ready, type the commands below on the terminal.
You should see the output as below:
Go is a tool for managing Go source code. Usage: go
[arguments] The commands are: bug start a bug report build compile packages and dependencies clean remove object files and cached files doc show documentation for package or symbol env print Go environment information fix update packages to use new APIs fmt gofmt (reformat) package sources generate generate Go files by processing source get download and install packages and dependencies install compile and install packages and dependencies list list packages or modules mod module maintenance run compile and run Go program test test packages tool run specified go tool version print Go version vet report likely mistakes in packages Use "go help " for more information about a command. Additional help topics: buildmode build modes c calling between Go and C cache build and test caching environment environment variables filetype file types go.mod the go.mod file gopath GOPATH environment variable gopath-get legacy GOPATH go get goproxy module proxy protocol importpath import path syntax modules modules, module versions, and more module-get module-aware go get packages package lists and patterns testflag testing flags testfunc testing functions Use "go help " for more information about that topic.
That’s how you tell Go is installed and ready to use.
For more about how to use Go, visit the link below:
Now that you have downloaded and installed Go your Ubuntu system, you can start developing your Go projects.
You may also like the post below: