{"id":6802,"date":"2021-06-09T18:10:51","date_gmt":"2021-06-09T18:10:51","guid":{"rendered":"https:\/\/linuxways.net\/?p=6802"},"modified":"2021-06-09T18:10:51","modified_gmt":"2021-06-09T18:10:51","slug":"how-to-install-go-on-centos-8","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/how-to-install-go-on-centos-8\/","title":{"rendered":"How to Install Go on CentOS 8"},"content":{"rendered":"<p>Colloquially referred to as <a href=\"https:\/\/golang.org\/\">Golang<\/a> , Go is an open-source language developed by Google Inc for creating robust, efficient, and reliable software applications. Popular tools built using Go include Terraform, Kubernetes, Docker, Istio, and InfluxDB. Let\u2019s explore how you can install Go on an instance of CentOS 8.<\/p>\n<h2><strong>Prerequisites<\/strong><\/h2>\n<p>Just before you embark on the procedure of installing Go, ensure that you have the following in check.<\/p>\n<p>An instance of CentOS 8.<\/p>\n<p>A sudo user configured on your instance.<\/p>\n<p>A stable internet connection.<\/p>\n<p>That said, let us get along with the installation of Go language.<\/p>\n<h2><strong>Step 1: Update the system<\/strong><\/h2>\n<p>Right off the bat, log in and update your CentOS 8 server as shown.<\/p>\n<pre><strong>$ sudo dnf update<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"909\" height=\"387\" class=\"wp-image-6803\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-76.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-76.png 909w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-76-300x128.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-76-768x327.png 768w\" sizes=\"auto, (max-width: 909px) 100vw, 909px\" \/><\/strong><\/p>\n<p>Hit \u2018y\u2019 when prompted and press ENTER.<\/p>\n<h2><strong>Step 2: Download Go binary file<\/strong><\/h2>\n<p>The next step is to download the Go binary package which comes in a tarball file. This is available on the <a href=\"https:\/\/golang.org\/dl\/\">Go downloads page<\/a>. At the moment, the latest version of Go is Go version 1.16.5. This is likely to vary by the time you are viewing this guide.<\/p>\n<p>To download the Go compressed file on the terminal, use the <strong>wget <\/strong>command as shown.<\/p>\n<pre><strong>$ wget https:\/\/golang.org\/dl\/go1.16.5.linux-amd64.tar.gz<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"873\" height=\"368\" class=\"wp-image-6804\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-77.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-77.png 873w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-77-300x126.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-77-768x324.png 768w\" sizes=\"auto, (max-width: 873px) 100vw, 873px\" \/><\/strong><\/p>\n<p>To confirm the existence of the tarball file, use the ls command.<\/p>\n<pre><strong>$ ls<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"877\" height=\"177\" class=\"wp-image-6805\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-78.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-78.png 877w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-78-300x61.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-78-768x155.png 768w\" sizes=\"auto, (max-width: 877px) 100vw, 877px\" \/><\/strong><\/p>\n<p>Next, extract the tarball file to the <strong>\/usr\/local <\/strong>directory which is mostly used for installing software applications locally.<\/p>\n<pre><strong>$ sudo tar -xvf go1.16.5.linux-amd64.tar.gz -C \/usr\/local<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"880\" height=\"161\" class=\"wp-image-6806\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-79.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-79.png 880w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-79-300x55.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-79-768x141.png 768w\" sizes=\"auto, (max-width: 880px) 100vw, 880px\" \/><\/strong><\/p>\n<p>Again, use the ls command to verify the go directory in the <strong>\/usr\/local <\/strong>path.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"876\" height=\"350\" class=\"wp-image-6807\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-80.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-80.png 876w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-80-300x120.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-80-768x307.png 768w\" sizes=\"auto, (max-width: 876px) 100vw, 876px\" \/><\/strong><\/p>\n<h2><strong>Step 4: Configure environment variables<\/strong><\/h2>\n<p>We need to configure the $PATH variable to point the Linux system on the location of the Go executable binaries. These binaries are found under the <strong>\/usr\/local\/go\/bin <\/strong>path.<\/p>\n<p>So, add the line below to the<strong> ~\/.bashrc <\/strong>file.<\/p>\n<pre><strong>export PATH=$PATH:\/usr\/local\/go\/bin<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"872\" height=\"179\" class=\"wp-image-6808\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-81.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-81.png 872w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-81-300x62.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-81-768x158.png 768w\" sizes=\"auto, (max-width: 872px) 100vw, 872px\" \/><\/p>\n<p>Save the changes and exit the file. Next, load the environment variable into the shell session by invoking the <strong>source <\/strong>command as shown<\/p>\n<pre><strong>$ source ~\/.bashrc<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"879\" height=\"148\" class=\"wp-image-6809\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-82.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-82.png 879w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-82-300x51.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-82-768x129.png 768w\" sizes=\"auto, (max-width: 879px) 100vw, 879px\" \/><\/p>\n<p>Then verify if Go is installed by checking the version as shown<\/p>\n<pre><strong>$ go version<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"882\" height=\"237\" class=\"wp-image-6810\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-83.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-83.png 882w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-83-300x81.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-83-768x206.png 768w\" sizes=\"auto, (max-width: 882px) 100vw, 882px\" \/><\/p>\n<h2><strong>Step 5: Test go installation<\/strong><\/h2>\n<p>Before concluding this guide, we are going to test if Go was indeed correctly installed by creating a workspace and create a simple program.<\/p>\n<p>Here, we\u2019ll create a workspace which is a directory called <strong>greetings<\/strong> and later navigate into it.<\/p>\n<pre><strong>$ mkdir greetings &amp;&amp; cd greetings<\/strong><\/pre>\n<p>Next, create a go module as follows:<\/p>\n<pre><strong>$ go mod init greetings<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"895\" height=\"200\" class=\"wp-image-6811\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-84.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-84.png 895w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-84-300x67.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-84-768x172.png 768w\" sizes=\"auto, (max-width: 895px) 100vw, 895px\" \/><\/p>\n<p>Next, we will create a simple Go file.<\/p>\n<pre><strong>$ vim greetings.go<\/strong><\/pre>\n<p>We will write a simple Go program that prints a simple message to stdout as shown.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"876\" height=\"232\" class=\"wp-image-6812\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-85.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-85.png 876w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-85-300x79.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-85-768x203.png 768w\" sizes=\"auto, (max-width: 876px) 100vw, 876px\" \/><\/p>\n<p>Save and exit. Then run the Go program as shown.<\/p>\n<pre><strong>$ go run greetings.go<\/strong><\/pre>\n<p>You should get the output displayed as indicated.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"888\" height=\"161\" class=\"wp-image-6813\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-86.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-86.png 888w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-86-300x54.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-86-768x139.png 768w\" sizes=\"auto, (max-width: 888px) 100vw, 888px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>In this guide, we have demonstrated how to install Go on CentOS 8. It\u2019s our hope that you had an easy time doing the same on your CentOS 8 system.<\/p>","protected":false},"excerpt":{"rendered":"<p>Colloquially referred to as Golang , Go is an open-source language developed by Google Inc for creating robust, efficient, and reliable software applications. Popular tools built using Go&hellip;<\/p>","protected":false},"author":1,"featured_media":7119,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[93,320],"class_list":["post-6802","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","tag-centos-8","tag-go"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/6802","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=6802"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/6802\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/7119"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=6802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=6802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=6802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}