{"id":17167,"date":"2022-05-18T09:27:21","date_gmt":"2022-05-18T09:27:21","guid":{"rendered":"https:\/\/linuxways.net\/?p=17167"},"modified":"2022-05-18T09:27:21","modified_gmt":"2022-05-18T09:27:21","slug":"how-to-install-golang-in-ubuntu","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-install-golang-in-ubuntu\/","title":{"rendered":"How to Install Golang in Ubuntu"},"content":{"rendered":"<p>Go, sometimes known as &#8220;Golang,&#8221; is considered the most widely used programming language. The first version of Go, version 1.0, was released in November 2012, and it was created by Google. It enables you to design applications that are more attractive and reliable. The programming language Go is compiled. You must first construct a source code to create an executable file that will aid in the software&#8217;s execution. Go programming is used to create many popular platforms, including Docker, Kubernetes, Terraform, and Prometheus. It is a cross-platform, open-source programming language that may be used on Windows, Mac OS X, and Linux. In this article, we&#8217;ll discuss how we can install the GO programming language on Ubuntu 20.04.<\/p>\n<h2>Install Golang on Ubuntu 20.04<\/h2>\n<p>Go can be installed on the Ubuntu 20.04 system by different installation techniques. Here, we&#8217;ll look at two possible approaches to installing the Go language:<\/p>\n<ul>\n<li>Installation of Golang using Ubuntu apt repository<\/li>\n<li>Installation of Golang by downloading the source code<\/li>\n<\/ul>\n<h2>Method 1: Installation of Golang using Ubuntu apt repository<\/h2>\n<p>The official Ubuntu apt repository occasionally contains out-of-date Golang applications. The apt package manager, on the other hand, makes it simple to install Golang packages. Access the terminal window by pressing &#8216;Ctrl+Alt+t&#8217;. To install Go on an Ubuntu 20.04 system, update the packages list and enter the following command:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre>$ sudo apt upgrade &amp;&amp; sudo apt update<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"719\" height=\"521\" class=\"wp-image-17168\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-4.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-4.png 719w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-4-300x217.png 300w\" sizes=\"auto, (max-width: 719px) 100vw, 719px\" \/><\/p>\n<p>Then, execute the following command to install Golang in Ubuntu:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre>$ sudo apt install golang<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"413\" class=\"wp-image-17169\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-5.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-5.png 720w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-5-300x172.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/p>\n<p>When it prompts for confirmation of the installation of Go packages, enter the &#8216;y&#8217; key and the &#8216;Enter&#8217; key. All essential Go dependencies will be installed on your machine after confirmation. You can easily verify the installation of Go by using the following command in the terminal to see the installed Go version:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre>$ go version<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"350\" height=\"92\" class=\"wp-image-17170\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-6.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-6.png 350w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-6-300x79.png 300w\" sizes=\"auto, (max-width: 350px) 100vw, 350px\" \/><\/p>\n<p>It can be seen from the above output that this machine has the default Go version 1.13.8 installed.<\/p>\n<h2>Method-2: Installation of Golang by downloading the source code<\/h2>\n<p>The most recent version of the Go programming language is required by the majority of software applications. In this case, you&#8217;ll be required to update your Ubuntu system to the latest Go version. At the time of writing, Go 1.17.1 was the most recent stable version available for installation. Check the latest version of Go on the official Go downloads page before downloading the binary archive. To install Go using the source code method; you can follow the following steps which are mentioned below:<\/p>\n<h3>Step 1: Save the Go binary archive<\/h3>\n<p>To locate and download the most recent stable version of Go, use the wget command on an Ubuntu 20.04 machine:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre>$ wget https:\/\/golang.org\/dl\/go1.17.1.linux-amd64.tar.gz<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>After you run the preceding command, a compressed tar file will be downloaded to your computer.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"725\" height=\"502\" class=\"wp-image-17171\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-timeline-description-automatically-generate.png\" alt=\"Text, timeline Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-timeline-description-automatically-generate.png 725w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-timeline-description-automatically-generate-300x208.png 300w\" sizes=\"auto, (max-width: 725px) 100vw, 725px\" \/><\/p>\n<h3>Step 2: Extract the binary archive<\/h3>\n<p>Run the following command to extract the tar into the \/usr\/local directory once the Go binary archive has been downloaded:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre>$ tar -xzf go1.17.1.linux-amd64.tar.gz -C \/usr\/local\/<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"685\" height=\"53\" class=\"wp-image-17172\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/word-image-14.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/word-image-14.png 685w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/word-image-14-300x23.png 300w\" sizes=\"auto, (max-width: 685px) 100vw, 685px\" \/><\/p>\n<h3>Step 3: Change the GO route variable<\/h3>\n<p>To tell the system where to seek Go executable binaries, we&#8217;ll add the Go directory path to the environment variable. The path to the Go directory can be added to either the \/etc\/profile file for a system-wide installation (which we will do here) or the $Home\/.profile file for a specific user installation (which we will do here). Open the file &#8216;\/etc\/profile&#8217; in a source code editor as follows:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre>$ sudo nano \/etc\/profile<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Add the following path after pressing enter at the end of the file.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre>$ export PATH=$PATH:\/usr\/local\/go\/bin<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"725\" height=\"526\" class=\"wp-image-17173\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-7.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-7.png 725w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-7-300x218.png 300w\" sizes=\"auto, (max-width: 725px) 100vw, 725px\" \/><\/p>\n<p>You can press &#8216;Ctrl+O&#8217; to save your changes, and then press &#8216;Ctrl+X&#8217; to leave this file.<\/p>\n<p>Activate the PATH environment variable by running the command (\/etc\/profile\/source)<\/p>\n<p>Finally, use the terminal command to verify the Go language version that is installed:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre>$ go version<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"386\" height=\"64\" class=\"wp-image-17174\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-8.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-8.png 386w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-8-300x50.png 300w\" sizes=\"auto, (max-width: 386px) 100vw, 386px\" \/><\/p>\n<h2>Remove and uninstall Go<\/h2>\n<p>Remove the file where the binary archive is extracted as follows if you do not wish to use Go any longer on your system:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre>$ sudo rm \u2013rf \/usr\/local\/go<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"410\" height=\"52\" class=\"wp-image-17175\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-9.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-9.png 410w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-9-300x38.png 300w\" sizes=\"auto, (max-width: 410px) 100vw, 410px\" \/><\/p>\n<h2>Conclusion<\/h2>\n<p>In this article, we\u2019ve discussed how to install Go or Golang on an Ubuntu 20.04 system using various installation techniques. We&#8217;ve also gone through how to develop and run the GO application on your PC after it&#8217;s been installed.<\/p>","protected":false},"excerpt":{"rendered":"<p>Go, sometimes known as &#8220;Golang,&#8221; is considered the most widely used programming language. The first version of Go, version 1.0, was released in November 2012, and it was&hellip;<\/p>","protected":false},"author":1,"featured_media":17281,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[1004,31],"class_list":["post-17167","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu","tag-golang","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/17167","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=17167"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/17167\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/17281"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=17167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=17167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=17167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}