{"id":4604,"date":"2019-05-15T23:38:14","date_gmt":"2019-05-15T18:08:14","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=4604"},"modified":"2026-10-22T18:45:33","modified_gmt":"2026-10-22T13:15:33","slug":"how-to-install-go-on-centos-7","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/how-to-install-go-on-centos-7\/","title":{"rendered":"How to Install Go on CentOS-7"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Post Date:<\/strong> May 15, 2019 <br><strong>Last Updated:<\/strong> October 22, 2026<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This guide explains how to install Go on CentOS 7. Go, often called Golang, is an open source programming language created by Google. Many well-known tools, including Docker, Kubernetes, and Hugo, are written in it. If you&#8217;re looking for how to install Golang on CentOS 7, the tarball method below is the one Go&#8217;s own documentation recommends.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The original guide used Go 1.12.5, which is long out of date. The steps below use a <code>&lt;VERSION&gt;<\/code> placeholder so you always install a current release. I also added three things the original left out: removing any old Go installation first, comparing the checksum against the published value, and checking that the install actually works.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> CentOS 7 reached end-of-life in June 2024. To install Go on CentOS 7 today, these steps still work, and since Go comes as a standalone tarball, the same steps also work on AlmaLinux, Rocky Linux, and most other Linux distributions.<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before you install Go on CentOS 7, make sure you have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Root or sudo access<\/li>\n\n\n\n<li><code>wget<\/code> or <code>curl<\/code> installed<\/li>\n\n\n\n<li>The current Go version number, from the <a href=\"https:\/\/go.dev\/dl\/\" target=\"_blank\" rel=\"noopener\">official Go downloads page<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Architecture<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go ships as a self-contained toolchain. Extracting the tarball puts everything in one folder, <code>\/usr\/local\/go<\/code><\/li>\n\n\n\n<li>The <code>go<\/code> command, the compiler, and other tools live in <code>\/usr\/local\/go\/bin<\/code>. Your shell can only run them if that folder is in your <code>PATH<\/code><\/li>\n\n\n\n<li>When you run <code>go build<\/code>, the toolchain compiles your source code into a standalone binary that you can copy to another server and run<\/li>\n\n\n\n<li>Because it&#8217;s just a tarball, you can install Golang on CentOS 7 without touching the system package manager<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The image below shows what happens when you install Go on CentOS 7, from the downloaded tarball to a working <code>go<\/code> command:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/05\/image-7.png\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"568\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/05\/image-7-1024x568.png\" alt=\"\" class=\"wp-image-12436\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/05\/image-7-1024x568.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/05\/image-7-300x166.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/05\/image-7-768x426.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/05\/image-7.png 1530w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">For the official reference, see Go&#8217;s <a href=\"https:\/\/go.dev\/doc\/install\" target=\"_blank\" rel=\"noopener\">installation instructions<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to Install Go on CentOS 7<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Download the Tarball<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Check the <a href=\"https:\/\/go.dev\/dl\/\" target=\"_blank\" rel=\"noopener\">downloads page<\/a> for the current version, then download it:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">wget https:\/\/go.dev\/dl\/go&lt;VERSION>.linux-amd64.tar.gz\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>&lt;VERSION&gt;<\/code> with the version number shown on the page.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Verify the Checksum<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sha256sum go&lt;VERSION>.linux-amd64.tar.gz\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Compare the output with the SHA256 value listed beside that file on the downloads page. They must match exactly. If they don&#8217;t, delete the file and download it again.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> The original guide showed a checksum output but never said to compare it against anything. A checksum only protects you if you check it against the published value. Its sample hash also belonged to Go 1.12.5, so it won&#8217;t match any other version.<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">3. Remove Any Old Installation and Extract<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Remove a previous Go installation first, if there is one:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo rm -rf \/usr\/local\/go\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then extract the new tarball into <code>\/usr\/local<\/code>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo tar -C \/usr\/local -xzf go&lt;VERSION>.linux-amd64.tar.gz\n<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Go&#8217;s documentation warns against extracting a new version over an existing <code>\/usr\/local\/go<\/code> folder. Mixing old and new files can leave you with a broken installation, so always delete the old folder first. Once the archive is extracted, the main work to install Go on CentOS 7 is done. The rest is making the command available.<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">4. Set the Go PATH Environment Variable<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Setting the Go PATH environment variable tells your system where to find the Go binaries. For your own user:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">echo 'export PATH=$PATH:\/usr\/local\/go\/bin' >> ~\/.bash_profile\nsource ~\/.bash_profile\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For every user on the system, add that same <code>export PATH=$PATH:\/usr\/local\/go\/bin<\/code> line to <code>\/etc\/profile<\/code> instead.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. Verify the Installation<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The original guide stopped before this step. Confirm Go runs and reports the version you installed:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">go version\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">6. Run a Test Program (Optional)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">After you install Go on CentOS 7, a small program confirms the whole toolchain works:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mkdir -p ~\/hello &amp;&amp; cd ~\/hello\ngo mod init hello\ncat > main.go &lt;&lt; 'EOF'\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n    fmt.Println(\"Hello, Go on CentOS 7\")\n}\nEOF\ngo run .\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You should see <code>Hello, Go on CentOS 7<\/code> printed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you can&#8217;t install Go on CentOS 7 cleanly, check these:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>go: command not found<\/code>:<\/strong> the Go PATH environment variable hasn&#8217;t loaded. Run <code>source ~\/.bash_profile<\/code> or open a new session, then check with <code>echo $PATH<\/code><\/li>\n\n\n\n<li><strong>An old version still runs:<\/strong> another Go earlier in your <code>PATH<\/code>, often one installed with <code>yum install golang<\/code>, is taking priority. Find it with <code>which -a go<\/code> and remove the old package with <code>sudo yum remove golang<\/code><\/li>\n\n\n\n<li><strong>Permission denied while extracting:<\/strong> writing to <code>\/usr\/local<\/code> needs <code>sudo<\/code><\/li>\n\n\n\n<li><strong>Strange build errors after upgrading:<\/strong> you probably extracted over an old installation. Remove <code>\/usr\/local\/go<\/code> and extract again<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To install Go on CentOS 7, download the current tarball, verify its checksum against the published value, remove any old copy, extract it to <code>\/usr\/local<\/code>, and add <code>\/usr\/local\/go\/bin<\/code> to your <code>PATH<\/code>. Finish with <code>go version<\/code> to confirm it works. Because the process uses a plain tarball, it&#8217;s the same on any Linux distribution, so it carries over if you later move to AlmaLinux, Rocky Linux, or Ubuntu.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Is the tarball the best way to install Go on CentOS 7?<\/strong> It&#8217;s the method Go&#8217;s own documentation recommends, and it gets you a current release. Distribution packages such as the one <code>yum install golang<\/code> provides often lag well behind the latest Go version.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Do I need root to install Go on CentOS 7?<\/strong> You need it to extract into <code>\/usr\/local<\/code>. Without root, you can extract to a folder in your home directory and add that folder&#8217;s <code>bin<\/code> directory to your <code>PATH<\/code> instead.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Can I install Golang on CentOS 7 with yum?<\/strong> You can, but the version is usually old. Use the tarball steps above for a current release.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>How do I upgrade Go later?<\/strong> Repeat Steps 1 to 3 with the new version number. Remove <code>\/usr\/local\/go<\/code> first, extract the new tarball, and run <code>go version<\/code> to confirm. Your <code>PATH<\/code> setting doesn&#8217;t need to change.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Articles<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-install-mysql-8-0-on-centos-7\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to install MySQL 8.0 on CentOS 7<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-install-openvz-7-on-centos-7\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Install OpenVZ 7 on CentOS 7<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Talk to Our Technology Experts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Building Go applications or setting up development and deployment environments? Our team can help with Go development, server setup, CI\/CD pipelines, and ongoing DevOps support.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/contact\">Connect with our technology experts.<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Post Date: May 15, 2019 Last Updated: October 22, 2026 Introduction This guide explains how to install Go on CentOS [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":12450,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[161,650,261],"class_list":["post-4604","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-architecture","tag-centos","tag-go-install","tag-linux","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-1cg","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/05\/Installing-Go-on-CentOS-7-1.png","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4604","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=4604"}],"version-history":[{"count":1,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4604\/revisions"}],"predecessor-version":[{"id":12437,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4604\/revisions\/12437"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media\/12450"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=4604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=4604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=4604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}