Introduction
This is another article presenting on how to install golang. The installation process is done in Ubuntu Linux 18.04. Actually, there is another similar article with the same content with this article. It exist in this link. But in this article, the process is using snap utility rather than using the normal package manager such as apt.
First of all, before starting to show how to install golang, what is snap utility actually ?. Therefore, search for further information about snap. There is a specific information about this utility with the name of snaps in this link. According to the link, snap is an applications compressed together with their dependencies and descriptions of how to run and interact with other software on the system you installed it on.
Moreover, the unique of the application are they mainly designed to be sandboxed and isolated from other system software, secure, and easily installable, upgradeable, degradable, and removable irrespective of its underlying system.
Installation Process
Below are steps for installing golang using snap utility :
1. First step, make sure that snap exists in the operating system. Just type the following command to execute the snap utility :
user@hostname:~$ snap The snap command lets you install, configure, refresh and remove snaps. Snaps are packages that work across many different Linux distributions, enabling secure delivery and operation of the latest apps and utilities. Usage: snap <command> [<options>...] Commands can be classified as follows: Basics: find, info, install, list, remove ...more: refresh, revert, switch, disable, enable History: changes, tasks, abort, watch Daemons: services, start, stop, restart, logs Commands: alias, aliases, unalias, prefer Configuration: get, set, wait Account: login, logout, whoami Permissions: interfaces, interface, connect, disconnect Snapshots: saved, save, check-snapshot, restore, forget Other: version, warnings, okay Development: run, pack, try, ack, known, download For more information about a command, run 'snap help <command>'. For a short summary of all commands, run 'snap help --all'. user@hostname:~$
2. Next, check the available tool or package exist. Obviously, check if it exists in the management of snap utility. Type the following command :
user@hostname:~$ snap list Name Version Rev Tracking Publisher Notes xxxxx x.x.x xxx stable xxxxx - xxxxxx-xxx x.x.x xx 70 stable xxxxx - ... user@hostname:~$
As shown in the above output, there is no utility with the name of go.
3. After that, switch to root account. It is necessary before installing the snap utility. Just type the following command to install go using snap :
root@hostname:~# snap install go error: This revision of snap "go" was published using classic confinement and thus may perform arbitrary system changes outside of the security sandbox that snaps are usually confined to, which may put your system at risk. If you understand and want to proceed repeat the command including --classic. root@hostname:~# snap install --classic go go 1.11.5 from Michael Hudson-Doyle (mwhudson) installed root@hostname:~#
Testing the go utility
After successfully installing go in the previous section, test whether ‘go’ utility exist. Below are those steps :
1. First of all, check if the go exist. It is to check whether the previous step for installing snap is success or not. Type the following command :
root@hostname:~# snap list Name Version Rev Tracking Publisher Notes xxxxx x.x.x xxx stable xxxxx - xxxxxx-xxx x.x.x xx 70 stable xxxxx - ... go 1.11.5 3129 stable mwhudson ... root@hostname:~#
The above command ‘snap list’ is for listing the package in snap management. Furthermore, in the output of the snap command exists the go utility.
2. Last but not least, switch to normal user account. In order to test the command, just start typing ‘go’ to execute the utility as follows :
user@hostname:~$ go Go is a tool for managing Go source code. Usage: go command [arguments] The commands are: build compile packages and dependencies clean remove object files and cached files doc show documentation for package or symbol env print Go environment information bug start a bug report 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 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 [command]" for more information about a command. Additional help topics: c calling between Go and C buildmode build modes cache build and test caching filetype file types gopath GOPATH environment variable environment environment variables importpath import path syntax packages package lists testflag testing flags testfunc testing functions Use "go help [topic]" for more information about that topic. user@hostname:~$
Since the command execution is a success, the installation process of ‘go’ is finished.