Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Programming»How To Install Go 1.17 on Ubuntu 18.04 & 16.04 LTS

    How To Install Go 1.17 on Ubuntu 18.04 & 16.04 LTS

    By RahulFebruary 14, 20222 Mins Read

    Go is an open-source programming language developed by a team at Google. It provides easy to build simple, reliable, and efficient software. This language is designed for writing servers, that’s why it is using widely these days. Go has released the latest version 1.17.

    Advertisement

    This tutorial will help you to install Go 1.17 on your Ubuntu 19.10, 18.04 LTS, 16.04 LTS, and 14.04 LTS systems.

    Step 1 – Install Go on Ubuntu

    Login to your Ubuntu system using ssh and upgrade to apply latest security updates there.

    sudo apt-get update  
    sudo apt-get -y upgrade  
    

    Now download the Go language binary archive file using following link. To find and download latest version available or 32 bit version go to official download page.

    wget https://dl.google.com/go/go1.17.7.linux-amd64.tar.gz 
    

    Now extract the downloaded archive and install it to the desired location on the system. For this tutorial, I am installing it under /usr/local directory. You can also put this under the home directory (for shared hosting) or other location.

    sudo tar -xvf go1.17.7.linux-amd64.tar.gz   
    sudo mv go /usr/local  
    

    Step 2 – Setup Go Environment

    Now you need to setup Go language environment variables for your project. Commonly you need to set 3 environment variables as GOROOT, GOPATH and PATH.

    • GOROOT is the location where Go package is installed on your system.
      export GOROOT=/usr/local/go 
      
    • GOPATH is the location of your work directory. For example my project directory is ~/Projects/Proj1 .
      export GOPATH=$HOME/Projects/Proj1 
      
    • Now set the PATH variable to access go binary system wide.
      export PATH=$GOPATH/bin:$GOROOT/bin:$PATH 
      

    All the above environment will be set for your current session only. To make it permanent add above commands in ~/.profile file.

    Step 3 – Verify Installation

    At this step, you have successfully installed and configured go language on your system. First, use the following command to check the Go version.

    go version 
    
    go version go1.17.7 linux/amd64
    

    Now also verify all configured environment variables using following command.

    go env 
    
    GOARCH="amd64"
    GOBIN=""
    GOCACHE="/root/.cache/go-build"
    GOEXE=""
    GOHOSTARCH="amd64"
    GOHOSTOS="linux"
    GOOS="linux"
    GOPATH="/root/Projects/Proj1"
    GORACE=""
    GOROOT="/usr/local/go"
    GOTMPDIR=""
    GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
    GCCGO="gccgo"
    CC="gcc"
    CXX="g++"
    CGO_ENABLED="1"
    ...
    ...
    

    Conclusion

    In this tutorial, you have learned to install latest Golang on Ubuntu 18.04 and 16.04 Linux systems.

    Go Golang Ubuntu
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    PHP Arrays: A Beginner’s Guide

    How to Create and Read List in Python

    Python Program to Add Two Numbers

    View 43 Comments

    43 Comments

    1. Aaron J on February 13, 2022 2:56 am

      Finally an article that works! Nice work man. After hours of wrestling with this trying to get “go install” to work you helped me a bunch!

      Reply
    2. Gaurav on June 22, 2021 2:33 pm

      thanks man!

      Reply
    3. Askat on November 5, 2019 4:46 am

      You forgot to say sudo ln -s /usr/local/go/bin/go /usr/bin/go

      Reply
    4. Keisuke Yasuda on November 1, 2019 3:12 am

      It helps me a lot, Thanks!

      Reply
    5. Everton Marques on September 17, 2019 7:04 pm

      update-golang is a script to easily fetch and install new Golang releases:

      git clone https://github.com/udhos/update-golang
      cd update-golang
      sudo ./update-golang.sh

      Reply
    6. KopoNeo on September 2, 2019 12:39 pm

      nice work, thanks a lot

      Reply
    7. Aaro on August 18, 2019 9:44 am

      That was helpful, thanks man.

      Reply
    8. Coenraad Loubser on July 19, 2019 8:59 am

      Or just go to https://github.com/golang/go/wiki/Ubuntu

      Reply
    9. Mike on July 6, 2019 2:14 am

      Best tech support site ever.

      Reply
    10. Rico on June 29, 2019 7:36 am

      nice work!

      Reply
    11. goodguy on June 28, 2019 10:31 am

      I need such short tutorial, Thanks Rahul

      Reply
    12. rajwinder on June 18, 2019 3:15 am

      Thank you sir

      Reply
    13. R Yadav on June 11, 2019 9:42 am

      Thanks bhai

      Reply
    14. Karen Avetyan on May 22, 2019 12:22 pm

      There is a Snap package available for Go. https://snapcraft.io/go
      It can be installed on Ubuntu systems with the following command:

      sudo snap install go –classic

      P.S. When installing snap there is no need to add PATH variables.

      Reply
    15. Ed Barbar on May 16, 2019 9:04 am

      Thanks! I finally found this when I couldn’t get apt-get xxx working. This works great.

      Reply
    16. irfan on May 11, 2019 5:57 pm

      where will i get ~/.profile file?

      Reply
    17. JOSUKE on February 20, 2019 9:56 am

      yo, nice work Rahul !!!

      Reply
    18. ADITYA NUGUR on January 22, 2019 7:54 pm

      Awful ! I tried migrating from Go 10 to Go 11 using ur approach. I had many projects in ~/go folder and it was merged with go 11 contents and I realized what was happening when my move failed. Lucky me!! but things got too messy to separate new files. You should have had a caution or something to rename existing ~/go folder to something.

      Reply
    19. rs on January 16, 2019 2:10 pm

      Hello Sir,

      Tecadmin really very helpful for me.

      I am follow all your tutorials and topics.Now i want one suggestion for new topic is: for webRTC ( turnserver, go, and collider) installation on ubuntu 17.10.

      If you can it’s very very for me.

      In advance Thank you

      Reply
    20. Vipul on November 3, 2018 4:49 am

      Thanks Rahul

      Reply
    21. Patrik F. on June 30, 2018 2:06 pm

      Amazing, thanks. Only one point would be that official repository go-golang package puts executables to /usr/bin so maybe would be better to keep it consistent for people that switch from outdated version?

      Reply
    22. Barry Black on February 23, 2018 3:13 am

      Thank you

      Reply
    23. Nitheesh on February 6, 2018 8:29 am

      thanks rahul

      Reply
    24. Felipe Ortiz de Almeida on January 21, 2018 1:35 pm

      For ensuring that all works, I have added the environment variables in “~/.bashrc”, “~/.profile” and ” /etc/profile” too. Well, it’s working. Thank you!

      Reply
    25. OLA on December 20, 2017 11:30 pm

      Good work

      Reply
    26. ravi on December 13, 2017 7:43 pm

      IT is not working after this
      All above environment will be set for your current session only. To make it permanent add above commands in ~/.profile file.

      Reply
    27. ravi on December 13, 2017 7:24 pm

      how to remove golang make a page of that to

      Reply
    28. Alexey on November 28, 2017 2:59 am

      Thank you Rahul for the comprehensive guide!

      Reply
    29. Raj on November 21, 2017 10:07 am

      Thanks dude !!

      Reply
    30. Tom W. on November 20, 2017 3:31 pm

      Thanks! Painless and easy

      Reply
    31. froot on November 17, 2017 8:25 am

      Thanks

      Reply
    32. Raul Borges on November 10, 2017 1:18 pm

      Thank you Rahul for this tutorial, very helpful

      Reply
    33. asd on October 16, 2017 10:56 pm

      ty

      Reply
    34. luis pazos on October 5, 2017 1:25 pm

      Gracias, al fin instale go1.9 🙂

      Reply
    35. Husain on August 26, 2017 4:48 pm

      Thanks

      Reply
    36. rahul on August 24, 2017 6:09 am

      Thanks

      Reply
    37. Sudarshan on August 20, 2017 1:49 pm

      Thank you for a wonderful tutorial .I am lost for the steps when it said “All above environment will be set for your current session only. To make it permanent add above commands in ~/.profile file. ”

      I am quite new to this and need a stepwise instructions just like you have given in installing golang. Kindly help. THANK YOU !!!!

      Reply
    38. Adem Kerenci on July 29, 2017 6:38 pm

      In my case, I am using Ubuntu 16.04.02 LTS, putting the GOROOT, GOPATH and PATH environmental variables to .profile does not work, I just try to put to .bashrc and it works. Btw, thanks for easy workaround for go.

      Reply
    39. gorunit on July 16, 2017 11:20 pm

      Great, straightforward tutorial. Thanks!

      Reply
    40. Nick on October 16, 2016 4:02 am

      Also,

      $ sudo mv go /usr/local

      Shoould read

      $ sudo mv go /usr/local/go

      Reply
      • Elliott Beach on July 23, 2017 5:07 pm

        Why explicitly state the target filename? The published version will work if required directories exist as expected.

        Reply
    41. Roman on September 26, 2016 11:08 pm

      GOPATH is the location of your work directory. For example my project directory is ~/Projects/Proj1 .
      $ export GOROOT=$HOME/Projects/Proj1

      Correct value is:
      $ export GOPATH=$HOME/Projects/Proj1

      Reply
      • Rahul K. on September 28, 2016 9:40 am

        Thanks Roman,

        I have updated tutorial.

        Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to List Manually Installed Packages in Ubuntu & Debian
    • 10 Bash Tricks Every Developer Should Know
    • How to Validate Email Address in JavaScript
    • Firewalld: Common Firewall Rules and Commands
    • 12 Apk Commands in Alpine Linux Package Management
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.