0% found this document useful (0 votes)
36 views4 pages

Upgrading or Downgrading Go - Practical Go Lessons-40

Uploaded by

prsnortin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views4 pages

Upgrading or Downgrading Go - Practical Go Lessons-40

Uploaded by

prsnortin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Upgrading or Downgrading Go - Practical Go Lessons https://www.practical-go-lessons.

com/chap-40-upgrading-or-downgrading-go

Chapter 40: Upgrading or Downgrading Go

1 What will you learn in this chapter?


• How to upgrade (or downgrade) Go on your computer.

2 Technical concepts covered


• SHA256

3 Checking your version


To get the currently installed version of Go, just type :

$ go version

This will output something like that :

go version go1.11.1 darwin/amd64

The version is printed with the reference of your system (in my case Apple MacOS)

The paper and the digital edition of this book are available here. ×
I also filmed a video course to build a real world project with Go.

4 Where is your Go binary?


To upgrade your system to a new version of go, you have to locate where Go is on your system.

$ which go

Wich will locate the program file in the user path (cf. man which)

Usually (Linux and Mac users), if you type this on your system, it will display :

/usr/local/go/bin/go

For windows users, the path where the go binaries are stored is usually.

C:\Go\bin

To be sure, you can run the command :

1 of 4 02/01/2023, 02:24
Upgrading or Downgrading Go - Practical Go Lessons https://www.practical-go-lessons.com/chap-40-upgrading-or-downgrading-go

c:\> where go

We have successfully located the binaries; now we can upgrade it

5 Download a new version


New versions of Go are hosted on the golang.org website here: https://golang.org/dl/. Always download your go version from this official
URL.

To update your current version, download on this website the targeted version.

To be sure that you have downloaded a valid binary, you have to compute the SHA256 sum of the downloaded file. Then you have to
ensure that it is strictly equal to the one that is listed on the website (see 1).

Webpage to download go binaries[fig:Webpage-to-download]

5.0.0.1 On macOS
To check a sha256 sum, open a terminal and type :

$ shasum -a 256 go1.11.2.linux-amd64.tar.gz

The a flag is used to indicate which algorithm to use (here it’s SHA256)

5.0.0.2 On Linux
The command is shorter :

$ sha256sum go1.11.2.linux-amd64.tar.gz

5.0.0.3 On Windows
You can use certutil to do so on the command prompt

> certutil -hashfile go1.11.2.linux-amd64.tar.gz SHA256

6 Install the (new/old) version


6.1 On macOS
You downloaded an installer. It will automatically install the selected version. Just double-click on the file downloaded.

6.2 On Linux
6.2.0.0.1 Archive extraction
First, you have to extract the archive downloaded with the following command :

$ sudo tar -C /usr/local -xzf go1.11.2.linux-amd64.tar.gz

It will extract the contents of the tar.gz file into /usr/local :

2 of 4 02/01/2023, 02:24
Upgrading or Downgrading Go - Practical Go Lessons https://www.practical-go-lessons.com/chap-40-upgrading-or-downgrading-go

Contents of /usr/local/go (Go v.1.16)

The bin directory contains two executables files at the time of writing :

• go

• gofmt

6.2.0.0.2 PATH modification


To be able to launch go and gofmt commands, you will need to add this directory to your PATH. To do so, add this line at the top of the file
.bashrc located in your home directory. (or .zshrc if you use zsh) :

export PATH=$PATH:/usr/local/go/bin

After that, you will need to restart your terminal for the change to take effect.

6.3 On Windows
You downloaded an installer. it will automatically install the selected version. Just double-click on the file downloaded.

Bibliography
Previous Next

An object oriented programming language ? Design Recommendations

Table of contents

Did you spot an error ? Want to give me feedback ? Here is the feedback page! ×

Newsletter:
Like what you read ? Subscribe to the newsletter.

I will keep you informed about the book updates.

@ my@email.com

Practical Go Lessons
By Maximilien Andile
Copyright (c) 2023
Follow me Contents

3 of 4 02/01/2023, 02:24
Upgrading or Downgrading Go - Practical Go Lessons https://www.practical-go-lessons.com/chap-40-upgrading-or-downgrading-go

Posts
Book
Support the author Video Tutorial

About
The author
Legal Notice
Feedback
Buy paper or digital copy
Terms and Conditions

4 of 4 02/01/2023, 02:24

You might also like