{"id":153,"date":"2019-12-02T10:54:00","date_gmt":"2019-12-02T13:54:00","guid":{"rendered":"https:\/\/www.linuxpro.com.br\/2019\/12\/install-golang-linux\/"},"modified":"2026-09-08T03:04:41","modified_gmt":"2026-09-08T06:04:41","slug":"install-golang-linux","status":"publish","type":"post","link":"https:\/\/www.linuxpro.com.br\/en\/2019\/12\/install-golang-linux\/","title":{"rendered":"Installing Golang on Linux"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" alt=\"Mascote do LinuxPro pegando um cubo do pacote Go, com o fluxo de build indo para a pasta de sa\u00edda\" src=\"\/wp-content\/uploads\/2026\/09\/install-golang-linux-v3.webp\" width=\"1052\" height=\"652\" \/><\/p>\n<div style=\"background:#fff8e1;border-left:4px solid #8b1a1a;padding:.8em 1em;margin:1em 0\"><strong>Note (2026):<\/strong> The original post called for running a gist as root, a directory <code data-no-translation=\"\">~\/GO<\/code> and PATH in <code data-no-translation=\"\">\/etc\/profile<\/code>. That was in 2019. Below: the official tarball from go.dev (Go 1.27 series, released in August 2026), snap, and apt \u2014 with <code data-no-translation=\"\">go.mod<\/code>, without a manually configured GOPATH.<\/div>\n<p>Go was born at Google in 2007 (Pike, Thompson, Griesemer) and became open source in 2009 \u2014 we tell that story in <a href=\"\/en\/2026\/09\/a-historia-da-linguagem-go\/\">The history of the Go language<\/a>. It compiles quickly, produces a binary, and provides concurrency with goroutines. Docker, Kubernetes, Terraform: Go. In 2019 this how-to downloaded a script. In 2026 the official path is the tarball from <a href=\"https:\/\/go.dev\/dl\/\">go.dev\/dl<\/a>.<\/p>\n<p><!-- more --><\/p>\n<h2>Official tarball (recommended)<\/h2>\n<p>Fetches the current stable version, checks the architecture, and installs into <code data-no-translation=\"\">\/usr\/local\/go<\/code>. Do not extract over an old tree \u2014 Go itself asks you to delete it first:<\/p>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">VER=$(curl -fsSL 'https:\/\/go.dev\/VERSION?m=text' | head -n1)\ncase $(uname -m) in\n  x86_64)  GOARCH=amd64 ;;\n  aarch64) GOARCH=arm64 ;;\n  *) echo \"arch n\u00e3o suportada\"; exit 1 ;;\nesac\ncd \/tmp\ncurl -fLO \"https:\/\/go.dev\/dl\/${VER}.linux-${GOARCH}.tar.gz\"\nsudo rm -rf \/usr\/local\/go\nsudo tar -C \/usr\/local -xzf \"${VER}.linux-${GOARCH}.tar.gz\"\n<\/code><\/pre>\n<p>Set PATH for your user, not in <code data-no-translation=\"\">\/etc\/profile<\/code> for root:<\/p>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">echo 'export PATH=$PATH:\/usr\/local\/go\/bin' &gt;&gt; ~\/.profile\necho 'export PATH=$PATH:$(go env GOPATH)\/bin' &gt;&gt; ~\/.profile\nsource ~\/.profile\ngo version\n<\/code><\/pre>\n<p>The default GOPATH is already <code data-no-translation=\"\">~\/go<\/code>. You do not need <code data-no-translation=\"\">mkdir ~\/GO<\/code>. The SHA-256 checksum for each file is at <a href=\"https:\/\/go.dev\/dl\/\">go.dev\/dl<\/a>. Starting with 1.21, the toolchain can download a newer version automatically if the <code data-no-translation=\"\">go.mod<\/code> requests it (<code data-no-translation=\"\">GOTOOLCHAIN<\/code>).<\/p>\n<h2>Snap and apt<\/h2>\n<p>If you want the distro package, be aware that it lags behind upstream. Ubuntu 24.04 packages around 1.22; Canonical's snap keeps up better:<\/p>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\"># snap (cl\u00e1ssico, atualiza sozinho)\nsudo snap install go --classic\ngo version\n\n# apt (est\u00e1vel da distro, costuma ser mais velho)\nsudo apt update\nsudo apt install -y golang-go git\ngo version\n<\/code><\/pre>\n<p>Do not mix snap, apt, and <code data-no-translation=\"\">\/usr\/local\/go<\/code> in the same PATH. Choose one. The PPA <code data-no-translation=\"\">longsleep\/golang-backports<\/code> still exists for Ubuntu LTS if the machine's apt version is too old.<\/p>\n<h2>Hello, module<\/h2>\n<p>Since 1.16, modules are the default. No more <code data-no-translation=\"\">GOPATH\/src\/github.com\/...<\/code>:<\/p>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">mkdir -p ~\/src\/hello &amp;&amp; cd ~\/src\/hello\ngo mod init hello\nprintf 'package mainnimport \"fmt\"nfunc main() { fmt.Println(\"ol\u00e1, linuxpro\") }n' &gt; hello.go\ngo run .\n<\/code><\/pre>\n<p>Generics have existed since 1.18 \u2014 the 2019 text said there were none. The gist from the original post (<a href=\"https:\/\/gist.github.com\/jniltinho\/8758e15a9ef80a189fce\">jniltinho\/8758e15a9ef80a189fce<\/a>) remains a relic: do not run gist scripts as root in 2026.<\/p>\n<h2>Wrap-up<\/h2>\n<p>One tarball, one PATH, one <code data-no-translation=\"\">go mod init<\/code>. The language that the 2017 list still called \u201cweak in Brazil\u201d is now the language of infrastructure. The overview: <a href=\"\/en\/2017\/05\/linguagens-de-programacao\/\">The 7 main programming languages<\/a>. The 2017 how-to, this one's older sibling: <a href=\"\/en\/2017\/05\/instalando-golang-no-linux\/\">Installing Golang on Linux<\/a>.<\/p>\n<p>With Go installed, see the language in action here on the blog \u2014 two of our projects written in Go: <a href=\"\/en\/2026\/09\/go-imapsync\/\">go-imapsync<\/a> (IMAP mailbox migration in a single binary) and <a href=\"\/en\/2026\/09\/go-postfixadmin\/\">go-postfixadmin<\/a> (a modern panel for Postfix).<\/p>\n<p>Docs: <a href=\"https:\/\/go.dev\/doc\/install\">go.dev\/doc\/install<\/a> \u00b7 tour: <a href=\"https:\/\/go.dev\/tour\/\">go.dev\/tour<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Go began at Google in 2007 (Pike, Thompson, Griesemer) and became open source in 2009 \u2014 we tell that story in The History of the Go Language. Fast compilation, one binary, concurrency with goroutines. Docker, Kubernetes, Terraform: Go. In 2019, this \u2026 <a title=\"Installing Golang on Linux\" class=\"read-more\" href=\"https:\/\/www.linuxpro.com.br\/en\/2019\/12\/install-golang-linux\/\" aria-label=\"Read more about Instalando Golang no Linux\">Read more<\/a><\/p>","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[29,31,32,30],"class_list":["post-153","post","type-post","status-publish","format-standard","hentry","category-dicas","tag-blog","tag-golang","tag-static-site","tag-zola"],"_links":{"self":[{"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/posts\/153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/comments?post=153"}],"version-history":[{"count":7,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/posts\/153\/revisions"}],"predecessor-version":[{"id":1093,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/posts\/153\/revisions\/1093"}],"wp:attachment":[{"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/media?parent=153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/categories?post=153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/tags?post=153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}