{"id":45493,"date":"2024-02-07T15:29:23","date_gmt":"2024-02-07T15:29:23","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=45493"},"modified":"2026-08-25T14:21:02","modified_gmt":"2026-08-25T14:21:02","slug":"how-to-install-go-golang-1-22-in-ubuntu-22-04","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2024\/02\/how-to-install-go-golang-1-22-in-ubuntu-22-04\/","title":{"rendered":"How to Install GO (golang 1.27) in Ubuntu 26.04 | 24.04 | 22.04"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-logo.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-45494\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-logo-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-logo-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-logo-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-logo-700x700.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-logo-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-logo.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>Go programming language announced the new 1.27 release on 19 August 2026! Here&#8217;s the new features and how to install guide for Ubuntu &amp; other Linux.<\/p>\n<h3>What&#8217;s New in Go 1.27:<\/h3>\n<ul>\n<li>New generic methods that can now declare their own type parameters.<\/li>\n<li>Add <code>encoding\/json\/v2<\/code> package with stricter defaults and significantly faster unmarshaling.<\/li>\n<li>Add <code>crypto\/mldsa<\/code> package implements ML-DSA (FIPS 204.<\/li>\n<li>New <code>uuid<\/code> package for generating and parsing UUIDs.<\/li>\n<li>New portable <code>simd<\/code> package (experimental).<\/li>\n<li><code>goroutineleak<\/code> is now a generally available.<\/li>\n<li>Compiler tools now support <code>@file<\/code> response files.<\/li>\n<li><code>go test<\/code> runs the <code>stdversion<\/code> vet check by default.<\/li>\n<li><code>go doc<\/code> gains <code>package@version<\/code> and executable-example support.<\/li>\n<li>The big-endian 64-bit PowerPC port now uses the ELFv2 ABI.<\/li>\n<li>Update unicode 15 to 17.<\/li>\n<\/ul>\n<p>See the <a href=\"https:\/\/go.dev\/doc\/go1.27\" target=\"_blank\" rel=\"noopener\">announcement<\/a> for more changes in Go 1.27.<\/p>\n<p><!--more--><\/p>\n<h3>How to Install Golang 1.27 in Ubuntu<\/h3>\n<h4>1. Download the Linux Tarball<\/h4>\n<p>Go provides official Linux tarball for i386, amd64, arm64, and armv6l CPU architecture types. They are available to download at the link below:<\/p>\n<div class=\"wp-block-buttons aligncenter\">\n<div class=\"wp-block-button is-style-fill\"><a class=\"wp-block-button__link has-vivid-cyan-blue-to-vivid-purple-gradient-background has-text-color has-background\" href=\"https:\/\/go.dev\/dl\/\" target=\"_blank\" rel=\"noreferrer noopener\">Download GO<\/a><\/div>\n<\/div>\n<p>In case you don&#8217;t know your system architecture type, press Ctrl+Alt+T to open terminal and run <code>dpkg --print-architecture<\/code> command to tell.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-51926\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/download-go127-700x479.webp\" alt=\"\" width=\"610\" height=\"417\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/download-go127-700x479.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/download-go127-300x205.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/download-go127-768x525.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/download-go127.webp 1257w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/p>\n<p>Or, run command to download the Linux tarball from command line (Here I use <code>amd64<\/code> package for modern Intel\/AMD for example):<\/p>\n<pre>cd ~\/Downloads &amp;&amp; wget -c https:\/\/go.dev\/dl\/go1.27.0.linux-amd64.tar.gz<\/pre>\n<p>As time goes on, Go lang may release newer versions when you see this tutorial. In the case, <strong>change the URL (usually the part of version number) in last command accordingly.<\/strong><\/p>\n<h4>2. Extract Go Tarball to \/usr\/local<\/h4>\n<p><b>NOTE: If you&#8217;re trying to update Go to newer version, it&#8217;s HIGHLY recommended to remove the old one (via command below) to avoid issues:<\/b><\/p>\n<pre>sudo rm -rf \/usr\/local\/go<\/pre>\n<p>After downloaded the tarball, open terminal (<code>Ctrl+Alt+T<\/code>), and run commands:<\/p>\n<ul>\n<li>Navigate to the folder that saved the tarball (usually Downloads folder):\n<pre>cd ~\/Downloads<\/pre>\n<\/li>\n<li>Then, extract the tarball to <code>\/usr\/local<\/code> directory:\n<pre>sudo tar -C \/usr\/local\/ -xzf go1.27.0.linux-amd64.tar.gz<\/pre>\n<p>Also <strong>replace package name <code>go1.27.0.linux-amd64.tar.gz<\/code> in the command according to which tarball you downloaded.<\/strong><\/li>\n<\/ul>\n<p>After successfully extracted the tarball, use <code>ls \/usr\/local<\/code> to verify. It will output a list of sub-folders including <code>go<\/code>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-51927\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/extract-go127-700x499.webp\" alt=\"\" width=\"610\" height=\"435\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/extract-go127-700x499.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/extract-go127-300x214.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/extract-go127.webp 768w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/p>\n<h4>3. Set PATH Environment Variable<\/h4>\n<p><b>a.) Add GOROOT to Your User PATH<\/b><\/p>\n<p>To let your Ubuntu system know where to find Go command, user can add it to the PATH. And, here <code>\/usr\/local\/go<\/code> is the GOROOT directory. You just need to add its <code>bin<\/code> sub-folder to the PATH.<\/p>\n<p>Without logging out, run the command below to set PATH environment, which <b>works until your close the terminal window or exit the command console<\/b>.<\/p>\n<pre>export PATH=$PATH:\/usr\/local\/go\/bin<\/pre>\n<p><b>To make it permanent,<\/b> open home folder, press Ctrl+H to view\/hide hidden files, then click edit the <b>.profile<\/b> file (or .bashrc). When file opens, add following lines and save it.<\/p>\n<pre># set PATH so it includes \/usr\/local\/go\/bin if it exists\r\nif [ -d \"\/usr\/local\/go\/bin\" ] ; then\r\n    PATH=\"\/usr\/local\/go\/bin:$PATH\"\r\nfi<\/pre>\n<p>This works for <strong>current user only<\/strong>, and applies in next login.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/add-gopath-2604.webp\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-51928\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/add-gopath-2604-700x582.webp\" alt=\"\" width=\"610\" height=\"507\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/add-gopath-2604-700x582.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/add-gopath-2604-300x249.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/add-gopath-2604-768x639.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/add-gopath-2604.webp 1038w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p><b>To set the PATH environment variable<\/b> for all users, create &amp; edit a config file under <code>\/etc\/profile.d<\/code> directory instead. To do so, run command:<\/p>\n<pre>sudo nano \/etc\/profile.d\/go.sh<\/pre>\n<p>Then, paste the same lines above. Press Ctrl+S to save, and Ctrl+X to exit. Also, log out and back in to apply.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go2path-system.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45498\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go2path-system-700x454.webp\" alt=\"\" width=\"610\" height=\"396\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go2path-system-700x454.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go2path-system-300x195.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go2path-system-768x498.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go2path-system.webp 822w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p><b>b.) Add GOPATH to Your User PATH<\/b><\/p>\n<p>Running <code>go install<\/code> command by default downloads &amp; installs packages to <code>go<\/code> sub-folder (<i>create automatically if not exist<\/i>) in user home. It&#8217;s called GOPATH.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/gopath.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45765\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/gopath-700x344.webp\" alt=\"\" width=\"610\" height=\"300\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/gopath-700x344.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/gopath-300x148.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/gopath-768x378.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/gopath.webp 1208w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>If you want to change GOPATH to another directory, for example <code>.local\/go<\/code>, either use command below that works for current terminal or current command console:<\/p>\n<pre>export GOPATH=$HOME\/.local\/go<\/pre>\n<p>Or, edit the <b>.profile<\/b> file in user home and add the line in the end to make it permanent at next login.<\/p>\n<p><b>To add GOPATH to your user PATH<\/b>, <strong>here I use the default GOPATH for example,<\/strong> either run command for current command console only:<\/p>\n<pre>export PATH=$PATH:$HOME\/go\/bin<\/pre>\n<p>Or, edit the <b>.profile<\/b> file and add following lines:<\/p>\n<pre># Add GOPATH to PATH if it exists\r\nif [ -d \"$HOME\/go\/bin\" ] ; then\r\n    PATH=\"$HOME\/go\/bin:$PATH\"\r\nfi<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-51929\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/add-gopath2path-700x513.webp\" alt=\"\" width=\"610\" height=\"447\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/add-gopath2path-700x513.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/add-gopath2path-300x220.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/add-gopath2path-768x563.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/add-gopath2path.webp 813w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/p>\n<p><b>NOTE: The GOPATH directory may NOT exist out-of-the-box. You need to log out and back in to apply it to user PATH on the folder creation (usually first time running <code>go install<\/code> command).<\/b><\/p>\n<p>Golang also has many other environment options, you may run <b>go env<\/b> command to print them, and run similar commands above to change the directories.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-51930\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/goenv-2604-700x526.webp\" alt=\"\" width=\"610\" height=\"458\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/goenv-2604-700x526.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/goenv-2604-300x225.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/goenv-2604-768x577.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/goenv-2604.webp 808w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/p>\n<h3>Create your First Go program<\/h3>\n<p>When done setting PATH Environment Variable, you can run command to verify go version:<\/p>\n<pre>go version<\/pre>\n<p>To create your first Go project, say <b>hello<\/b>, do following commands one by one:<\/p>\n<ul>\n<li>First, create a project folder named &#8216;hello&#8217; and navigate into that folder.\n<pre>mkdir hello &amp;&amp; cd hello<\/pre>\n<p>Then, initialize new module (here use <code>example\/hello<\/code> as module name) in current directory to create a <code>go.mod<\/code> file to manage dependency.<\/p>\n<pre>go mod init example\/hello<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-51931\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-create2604-700x331.webp\" alt=\"\" width=\"610\" height=\"288\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-create2604-700x331.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-create2604-300x142.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-create2604-768x363.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-create2604.webp 808w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/li>\n<li>Now, let&#8217;s create new file, <code>hello.go<\/code> for example, with your favorite text editor:\n<pre>nano hello.go<\/pre>\n<p>Then, add the first code and save it (<i>For nano, press Ctrl+S then Ctrl+X<\/i>):<\/p>\n<pre>package main\r\n\r\nimport \"fmt\"\r\n\r\nfunc main() {\r\n    fmt.Println(\"Hello, World!\")\r\n}<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-51932\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-firstcode-2604-700x524.webp\" alt=\"\" width=\"610\" height=\"457\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-firstcode-2604-700x524.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-firstcode-2604-300x225.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-firstcode-2604-768x575.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-firstcode-2604.webp 808w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/li>\n<li>Finally, either use <code>go run hello.go<\/code> command to run it. Or <code>go build hello.go<\/code> to build into an executable binary file<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-51933\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-run2604-700x524.webp\" alt=\"\" width=\"610\" height=\"457\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-run2604-700x524.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-run2604-300x225.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-run2604-768x575.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/go-run2604.webp 808w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/li>\n<\/ul>\n<h3>Uninstall Go<\/h3>\n<p>To uninstall golang, simply delete the go directory under \/usr\/local by running command:<\/p>\n<pre>sudo rm -rf \/usr\/local\/go<\/pre>\n<p>That&#8217;s it.<\/p>","protected":false},"excerpt":{"rendered":"<p>Go programming language announced the new 1.27 release on 19 August 2026! Here&#8217;s the new features and how to install guide for Ubuntu &amp; other Linux. What&#8217;s New in Go 1.27: New generic methods that can now declare their own type parameters. Add encoding\/json\/v2 package with stricter defaults and significantly faster unmarshaling. Add crypto\/mldsa package [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":45494,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,6],"tags":[2147],"class_list":["post-45493","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-news","tag-golang"],"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/45493","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=45493"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/45493\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/45494"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=45493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=45493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=45493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}