How to update golang version

How to update golang version

How to Update Go Version

Related Articles

How to update golang version. Смотреть фото How to update golang version. Смотреть картинку How to update golang version. Картинка про How to update golang version. Фото How to update golang version

golang: Calculate 30 days before H-1 Day From Today

If you are upgrading from an older version of Go you must first remove the existing version. Following is curated options to update Go to latest version. You can refer to Go official download page to get the latest version.

Linux

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the existing version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

Another way to uninstall Go:

One liner installer:

2. Install the new version

Go to the downloads page and download the binary release suitable for your system.

3. Extract the archive file

To extract the archive file:

4. Make sure that your PATH contains /usr/local/go/bin

Windows

MSI installer

The installer should put the c:\Go\bin directory in your PATH environment variable. You may need to restart any open command prompts for the change to take effect.

Setting environment variables under Windows

Under Windows, you may set environment variables through the “Environment Variables” button on the “Advanced” tab of the “System” control panel. Some versions of Windows provide this control panel through the “Advanced System Settings” option inside the “System” control panel.

Originally posted 2019-08-16 23:11:58.

udhos/update-golang

Use Git or checkout with SVN using the web URL.

Work fast with our official CLI. Learn more.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

How to update golang version. Смотреть фото How to update golang version. Смотреть картинку How to update golang version. Картинка про How to update golang version. Фото How to update golang version How to update golang version. Смотреть фото How to update golang version. Смотреть картинку How to update golang version. Картинка про How to update golang version. Фото How to update golang version

update-golang is a script to easily fetch and install new Golang releases with minimum system intrusion.

Table of Contents

The script is based on official installation instructions from https://go.dev/doc/install.

This is the default behavior:

1. Search for the latest binary release in https://go.dev/dl/.

2. The script uses local system OS and ARCH to download the correct binary release. It is not harmful to run the script multiple times. Downloaded releases are kept as cache under ‘/usr/local’. You can erase them manually.

By default, the script only detects actual releases (not beta releases, not release candidates). However one can force any specific non-final release:

3. The release is installed at ‘/usr/local/go’.

4. The path ‘/usr/local/go/bin’ is added to PATH using ‘/etc/profile.d/golang_path.sh’.

5. Only if needed, GOROOT is properly setup, also using ‘/etc/profile.d/golang_path.sh’.

The script DOES NOT ever modify the GOPATH variable.

You can customize the behavior by setting environment variables (see Customization below).

Before running the script, make sure you have an untampered copy by verifying the SHA256 checksum.

You can use the ‘remove’ option to undo update-golang.sh work:

You can use the ‘-declutter’ option to prevent caching downloaded archives:

$ git clone https://github.com/udhos/update-golang Cloning into ‘update-golang’. remote: Counting objects: 481, done. remote: Compressing objects: 100% (11/11), done. remote: Total 481 (delta 4), reused 9 (delta 2), pack-reused 468 Receiving objects: 100% (481/481), 70.22 KiB | 125.00 KiB/s, done. Resolving deltas: 100% (248/248), done. lab@ubu1:

$ cd update-golang lab@ubu1:

These environment variables are available for customization:

How do I update golang from command prompt on Windows?

Part of Go Language Collective

I have 1.7 version of golang and I want to update golang to 1.8 from command prompt. Uninstalling and Installing it again is always an option, but can I update it using commands on Windows 8.1?

5 Answers 5

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

Switch to Trending sort

Go can also be updated using the Chocolatey package manager. Run from an elevated shell to minimize the risk of installation issues.

I think that GVM could be a good option for that. GVM is an interface to manage Go versions in your computer. It allows you to change the Go version and even installing/uninstalling different golang versions by command prompt.

You can install a new version by typing:

Or even get a list of golang versions installed in your computer:

More information can be found on their website: https://github.com/moovweb/gvm

How to update golang version. Смотреть фото How to update golang version. Смотреть картинку How to update golang version. Картинка про How to update golang version. Фото How to update golang version

The «normal» way for Windows is to use the MSI package that can be found here : https://golang.org/dl/.

Now if you really want to do it from the command line, you will need to know the version (current is 1.13.4). There are several ways I can think of, including scraping the golang website or leveraging the Docker tags matching image with latest.
If you’re doing this for administrative reasons, the version can also easily just be an input variable in your system.

Updating golang on Ubuntu

I have Ubuntu 14.4.03. The default golang version which came with it was 1.2.1. I would like to update golang to 1.4 or higher.

After searching I found the way to do this would be to first delete current go installation and then re-install the new version.

I found the following go installation files in the following directory:

Which directory contains what? Which ones should I delete? What should be the location of new installation? It seems /usr/local is more normal. Then how come Ubuntu default is as above?

What would be the procedure to install a new version og golang?

How to update golang version. Смотреть фото How to update golang version. Смотреть картинку How to update golang version. Картинка про How to update golang version. Фото How to update golang version

11 Answers 11

ppa:evarlast/golang1.4 is not working for me. The manual way of installing Go is given below.

For more detailed installation instruction: Install the latest Golang on Linux

Step 1: Remove the existing golang

Step 2: Download the latest version from the official site. Click Here

Step 3: Extract it in /usr/local using the following command. I am using Go 1.11.4 here. You may need to replace the filename with the actual filename based on the version you have downloaded.

Step 4: Create .go directory in home. (It is easy to install the necessary packages without admin privilege)

Step 5: Set up the following environment variables

Check this link on how to set environment variables permanently.

Step 6: Update the go command

Step 7: Test the golang version

How to install the current version of Go in Ubuntu Precise

Part of Go Language Collective

17 Answers 17

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

Switch to Trending sort

[Updated (previous answer no longer applied)]

For fetching the latest version:

I like to use GVM for managing my Go versions in my Ubuntu box. Pretty simple to use, and if you’re familiar with RVM, it’s a nobrainer. It allows you to have multiple versions of Go installed in your system and switch between whichever version you want at any point in time.

Install GVM with:

and then it’s as easy as doing this:

The default flag at the end of the second command will set go1.1.1 to be your default Go version whenever you start a new terminal session.

How to update golang version. Смотреть фото How to update golang version. Смотреть картинку How to update golang version. Картинка про How to update golang version. Фото How to update golang version

I used following commands from GoLang official repository, it installed GoLang version 1.6 on my Ubuntu 14.04

Reference official GoLang Repo https://github.com/golang/go/wiki/Ubuntu it seems this ppa will always be updated in future.

ubuntu-lxc’ has no PPA named ‘ubuntu/lxd-stable’

[October 2015] Answer because the current accepted answer sudo apt-get install golang isn’t uptodate and if you don’t want to install GVM follow these steps.

Step by step installation:

Possible errors + fixes: (to be updated)

If you get a go version xgcc (Ubuntu 4.9.1-0ubuntu1) 4.9.1 linux/amd64 then you did something wrong, so check out this post: Go is printing xgcc version but not go installed version

How to update golang version. Смотреть фото How to update golang version. Смотреть картинку How to update golang version. Картинка про How to update golang version. Фото How to update golang version

i installed from source. there is a step-by-step tutorial here: http://golang.org/doc/install/source

Here is the most straight forward and simple method I found to install go on Ubuntu 14.04 without any ppa or any other tool.

As of now, The version of GO is 1.7

Get the Go 1.7.tar.gz using wget

Extract it and copy it to /usr/local/

You have now successfully installed GO. Now You have to set Environment Variables so you can use the go command from anywhere.

and add the following line to the end of file.

Now, All the commands in go/bin will work.

Check if the install was successful by doing

For offline Documentation you can do

Offline documentation will be available at http://localhost:6060

Some people here are suggesting to change the PATH variable.

It is not a good choice.

Changing that to /usr/local/go/bin is temporary and it’ll reset once you close terminal.

go command will only work in terminal in which you changed the value of PATH.

You’ll not be able to use any other command like ls, nano or just about everything because everything else is in /usr/bin or in other locations. All those things will stop working and it’ll start giving you error.

However, this is permanent and does not disturbs anything else.

How to update golang version. Смотреть фото How to update golang version. Смотреть картинку How to update golang version. Картинка про How to update golang version. Фото How to update golang version

I use this instruction to install the latest version of How to update golang version. Смотреть фото How to update golang version. Смотреть картинку How to update golang version. Картинка про How to update golang version. Фото How to update golang version

Remove the existing Go version:

Install the latest version of Go:

Set Go workspace to the environment variable:

How to update golang version. Смотреть фото How to update golang version. Смотреть картинку How to update golang version. Картинка про How to update golang version. Фото How to update golang version

If someone is looking for installing Go 1.8 the follow this:

And then install go

How to update golang version. Смотреть фото How to update golang version. Смотреть картинку How to update golang version. Картинка про How to update golang version. Фото How to update golang version

For the current release of Go:

Click the link above to visit the Go project’s downloads page and select the binary distribution that matches your operating system and processor architecture.

Official binary distributions are available for the FreeBSD, Linux, macOS, and Windows operating systems and the 32-bit (386) and 64-bit (amd64) x86 processor architectures.

If a binary distribution is not available for your combination of operating system and architecture you may want to try installing from source or installing gccgo instead of gc.

/go export GOPATH=

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

go version should show be

go version go1.6beta1 linux/amd64

go env should show be

These days according to the golang github with for Ubuntu, it’s possible to install the latest version of Go easily via a snap:

Using snaps also works quite well:

Potentially preferable to fussing with outdated and/or 3rd party PPAs

On recent Ubuntu (20.10) sudo apt-get install golang works fine; it will install version 1.14.

You can also use the update-golang script:

update-golang is a script to easily fetch and install new Golang releases with minimum system intrusion

Or maybe you could use this script to install Go and LiteIDE?

If you are unhappy with the answer provided, please comment instead of blindly down voting. I have used this setup for the last 4 years without any issue.

How to update golang version. Смотреть фото How to update golang version. Смотреть картинку How to update golang version. Картинка про How to update golang version. Фото How to update golang version

If you have ubuntu-mate, you can install latest go by:

I have a script to download and install the last go from official website

Setup your GOROOT, GOPATH and PATH:

Best way to install Go on Ubuntu is to download required version from here. Here you could have all stable and releases, along with archived versions.

after downloading you selected version you can follow further steps, i will suggest you to download tar.gz format for ubuntu machine:

this will remove all the local go code base but wait something more we have to do to remove fully from local, i was missing this step and it took so much time until I understood what i am missing so here is the purge stuff to remove from list

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *