Golang как обновить на windows

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?

Paweł Prażak's user avatar

Paweł Prażak

3,1111 gold badge27 silver badges42 bronze badges

asked Apr 23, 2017 at 9:50

Saransh's user avatar

4

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

Install using:

choco install golang -y

Update using:

choco upgrade golang -y

answered Apr 27, 2020 at 8:38

David's user avatar

DavidDavid

2913 silver badges3 bronze badges

3

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:

gvm install go1.4 -B
gvm use go1.4
export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.5

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

gvm list

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

answered Apr 23, 2017 at 10:02

Goma_BR's user avatar

2

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.

Once you know the version you need to download the file at https://dl.google.com/go/go<version>.windows-amd64.msi.
You can use something like wget for Windows or just Powershell capabilities :
Invoke-WebRequest -OutFile go1.13.4.windows-amd64.msi https://dl.google.com/go/go1.13.4.windows-amd64.msi

Then you can just use the MSI in quiet mode :
msiexec.exe /package go1.13.4.windows-amd64.msi /quiet

answered Nov 28, 2019 at 8:39

Mickael V.'s user avatar

Mickael V.Mickael V.

1,11911 silver badges21 bronze badges

If using Chocolatey mode of upgrade as David suggested, there is a possibility that the GOPATH defined on your system may not match with the existing one (if you had set a custom path via manual install).
Chocolatey, will install the Go binaries under %USERPROFILE%/go/bin —> C:\Program Files\Go\bin
So please ensure the path and update your environment variables accordingly.

Installation message may look something like below, if the path changes.

«Environment Vars (like PATH) have changed. Close/reopen your shell to
see the changes (or in powershell/cmd.exe just type refreshenv).
The upgrade of golang was successful.
Software installed as ‘msi’, install location is likely default.
«

answered Mar 13, 2021 at 0:23

Element-6's user avatar

A simple way is to use the update-golang script:

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

answered Apr 29, 2017 at 2:57

Everton's user avatar

EvertonEverton

12.7k10 gold badges47 silver badges59 bronze badges

5

In today’s post, we will talk about how to upgrade Go version on your computer. As mentioned on the official page, if you want to update go version, you first need to uninstall the original version.

Update Go on Debian/Ubuntu/Fedora Linux

Step-1: Uninstall the existing version

To uninstall go, you have to locate where Go is on your system (locate the program file in the user path)

which go

To make sure, you can run the command to find the Go source location:

where go

To uninstall, delete the /usr/local/go directory or the source directory which you have received as output in previous command with root user using the following command:

sudo rm -rf /usr/local/go

To check if you already remove go, run the below command; the system will prompt «command go not found»

go --version

Step-2: Install the new version

Go to the downloads page and download the version release which suitable for your system. You can read more at Getting started with GOLANG
To extract the archive file (remember to change the downloaded file’s path )

sudo tar -C /usr/local -xzf /home/golinuxcloud/Downloads/go1.19.3.linux-amd64.tar.gz

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

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

After that, you will need to restart your terminal for the change to take effect.
To check if you have installed Go successfully, run the below command. Confirm that the command prints the installed version of Go.

go --version

Update Go on Windows

Step-1: Uninstall the existing version

Go can be easily uninstalled using Add/Remove Programs in the Windows control panel:

ALSO READ: Golang Performance Comparison | Why is GO Fast?

1. Go to the Control Panel section, and double-click Add/Remove Programs.

2. In Add/Remove Programs, right-click the go version you want to uninstall (for example Go Programming Language amd64 go1.19.3) then follow the prompts.

3. Click Yes to confirm uninstall Go

How to PROPERLY upgrade GO version? [SOLVED]

Step-2: Install the new version

Go download: go to the download page and choose your version

Open the MSI file you downloaded and follow the prompts to install Go. By default, the installer will install Go to Program Files or Program Files (x86). You can change the location as per your environment. After installing, you will need to close and reopen any open command prompts so that changes to the environment made by the installer are reflected in the command prompt.
To check if you have installed Go successfully, run the below command. Confirm that the command prints the installed version of Go.

go --version

Upgrade using Chocolatey [Optional]

Chocolatey has the largest online registry of Windows packages. Chocolatey packages encapsulate everything required to manage a particular piece of software into one deployment artifact by wrapping installers, executables, zips, and/or scripts into a compiled package file. Go can also be updated using the Chocolatey package manager. Run from an elevated shell to minimize the risk of installation issues.

Install using:

choco install golang -y

Update using:

choco upgrade golang -y

Update Go on MacOS

Step-1: Uninstall the existing version

If you have used an installer, you can uninstall Go by using the same installer. If you have installed it from the source then rm -rf /usr/local/go

rm -rf $(echo $GOPATH)

Then, remove all entries related to go i.e. GOROOT, GOPATH from ~/.bash_profile and run

source ~/.bash_profile

If you installed Go with the macOS package, remove the /etc/paths.d/go file.

Step-2: Install the new version

Open the package file you downloaded and follow the prompts to install Go.

ALSO READ: Golang http — Create HTTPS Server and Client

The package installs the Go distribution to /usr/local/go. The package should put the /usr/local/go/bin directory in your PATH environment variable. You may need to restart any open Terminal sessions for the change to take effect.

Verify that you’ve installed Go by opening a command prompt and typing the following command. Confirm that the command prints the installed version of Go.

go version

Summary

Your Go is successfully updated. To update it you need to remove your existing go folder, then reinstall the newest version. Remember that we can use multiple versions of Golang on a computer.

References

https://go.dev/doc/install#install
https://go.dev/dl/

Can’t find what you’re searching for? Let us assist you.

Enter your query below, and we’ll provide instant results tailored to your needs.

How to update Golang in windows?


2 answers


@matteo To update Golang in Windows, you can follow these steps:

  1. Download the latest version of Golang from the official website.
  2. Unzip the downloaded binary into a folder of your choice.
  3. Update the PATH environment variable to point to the new Golang folder.
  4. Run the go version command in your terminal to verify the installation.

@matteo 

Here is a more detailed step-by-step guide:

  1. Visit the official Golang website (https://golang.org/dl/) and download the latest stable release for Windows. Choose either the 32-bit or 64-bit version depending on your system.
  2. After the download is complete, open the downloaded package (.msi file) and run the installer.
  3. In the Golang installer window, choose the destination folder where you want Golang to be installed. The default location is usually fine, but you can choose a different folder if you prefer.
  4. During the installation process, make sure to check the box that says «Add to PATH» to automatically add Golang to your system’s PATH environment variable. This allows you to access the Golang commands from any command prompt or terminal window.
  5. Once the installation is complete, open a new command prompt or terminal window and run the following command to verify the installed version of Golang:

If you see the new version number displayed, it means Golang has been successfully updated.

Note: If you already have an older version of Golang installed, it’s recommended to uninstall it first using the Control Panel’s «Uninstall a program» feature before installing the new version. This helps avoid any potential conflicts between different versions.

That’s it! You have successfully updated Golang on your Windows system.

Related Threads:

  • go

Ответы

Аватар пользователя Даниил Першин

Для обновления версии Go необходимо:

  1. Скачать новую версию Go с официального сайта: https://golang.org/dl/
  2. Установить новую версию, следуя инструкциям в разделе «Installing Go» для вашей операционной системы: https://golang.org/doc/install
  3. После установки новой версии Go, необходимо убедиться, что ваша система использует новую версию, а не старую. Для этого можно запустить команду go version в терминале. Если вывод команды соответствует новой версии, то установка прошла успешно.
  4. Если вы используете какие-либо сторонние инструменты или пакеты, которые зависят от версии Go, то необходимо обновить их соответственно.

Также можно воспользоваться инструкцией, которую написали в Хекслете.

Курсы по программированию на Хекслете

Backend-разработка

Разработка серверной части сайтов и веб-приложений

Обложка категории Backend-разработка

Frontend-разработка

Разработка внешнего интерфейса сайтов и веб-приложений и верстка

Обложка категории Frontend-разработка

Создание сайтов

Разработка сайтов и веб-приложений на JS, Python, Java, PHP и Ruby on Rails

Обложка категории Создание сайтов

Тестирование

Ручное тестирование и автоматизированное тестирование на JS, Python, Java и PHP

Обложка категории Тестирование

Аналитика данных

Сбор, анализ и интерпретация данных на Python

Обложка категории Аналитика данных

Интенсивные курсы

Интенсивное обучение для продолжающих

Обложка категории Интенсивные курсы

DevOps

Автоматизация настройки локального окружения и серверов, развертывания и деплоя

Обложка категории DevOps

Веб-разработка

Разработка, верстка и деплой сайтов и веб-приложений, трудоустройство для разработчиков

Обложка категории Веб-разработка

Математика для программистов

Обучение разделам математики, которые будут полезны при изучении программирования

Обложка категории Математика для программистов

JavaScript

Разработка сайтов и веб-приложений и автоматизированное тестирование на JS

Обложка категории JavaScript

Python

Веб-разработка, автоматическое тестирование и аналитика данных на Python

Обложка категории Python

Java

Веб-разработка и автоматическое тестирование на Java

Обложка категории Java

PHP

Веб-разработка и автоматическое тестирование на PHP

Обложка категории PHP

Ruby

Разработка сайтов и веб-приложений на Ruby on Rails

Обложка категории Ruby

Go

Курсы по веб-разработке на языке Go

Обложка категории Go

HTML

Современная верстка с помощью HTML и CSS

Обложка категории HTML

SQL

Проектирование базы данных, выполнение SQL-запросов и изучение реляционных СУБД

Обложка категории SQL

Git

Система управления версиями Git, регулярные выражения и основы командой строки

Обложка категории Git

Похожие вопросы

Solution 1

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:

gvm install go1.4 -B
gvm use go1.4
export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.5

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

gvm list

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

Solution 2

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

Install using:

choco install golang -y

Update using:

choco upgrade golang -y

Solution 3

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.

Once you know the version you need to download the file at https://dl.google.com/go/go<version>.windows-amd64.msi.
You can use something like wget for Windows or just Powershell capabilities :
Invoke-WebRequest -OutFile go1.13.4.windows-amd64.msi https://dl.google.com/go/go1.13.4.windows-amd64.msi

Then you can just use the MSI in quiet mode :
msiexec.exe /package go1.13.4.windows-amd64.msi /quiet

Related videos on Youtube

How to install Go in Windows 11 | Go Programming Language | GoLang

03 : 21

How to install Go in Windows 11 | Go Programming Language | GoLang

How to uninstall Golang on Windows 10

07 : 14

How to uninstall Golang on Windows 10

How to get Command-line arguments in Golang (Lesson 97)

14 : 45

How to get Command-line arguments in Golang (Lesson 97)

How to create a Windows Service using exe file

06 : 12

How to create a Windows Service using exe file

How To Run Windows Update From Command Line

13 : 49

How To Run Windows Update From Command Line

GOPATH Setup Windows 2021 | Golang Tutorial

09 : 04

GOPATH Setup Windows 2021 | Golang Tutorial

How To Run Windows 10 Update From Command Prompt

01 : 19

How To Run Windows 10 Update From Command Prompt

How to Install Go on Windows 10

07 : 53

How to Install Go on Windows 10

How to Build a Command Line (CLI) Application with Go

25 : 26

How to Build a Command Line (CLI) Application with Go

How to Compile and Run a Go Program from Command Prompt

07 : 04

How to Compile and Run a Go Program from Command Prompt

How to run other system commands from your Golang program

21 : 22

How to run other system commands from your Golang program

Upgrade Go in less than 3 minutes

02 : 53

Upgrade Go in less than 3 minutes

Comments

  • 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?

    • You should follow the installation instructions, which include upgrade instructions (by way of removal and installation). It’s done entirely from the command line (at least for Unix-based OSes).

  • This is poor form, telling people to make a blanket download of your utility and then invoking it via sudo. I looked at the repo and it looks relatively legit still poor form and should not be recommended.

  • Works for me, obrigada Everton/udhos :-)

  • In my personal experience gvm is not worth it. I’ve already had go set-up. I just wanted make the updating easier/faster. A couple of basic functionalities were not working. Doing it the regular way seems cleaner and better (to me).

  • Looks like it kind of worked for me :) had to simlink old /usr/bin/go which was still 1.6 to the newly installed /usr/local/go/bin/go afterwards.

  • sudo? sh? On windows?

  • @Joyston. As far as I know it doesn’t work on Windows(there is nothing about it on their website and I’m not a Windows user to be sure). However, it might work on the new bash for Windows 10. I’m not sure though.

  • this comment should really be removed since OP is asking for Windows.

  • worked like charm updating from go1.11 to go1.16

  • Works like a charm, thanks @David :)

  • Even if the first installation was from an installer?

Recents

Related

  • Gnu radio companion для windows
  • Go pro web camera windows
  • Global iris service windows 11 что это
  • Go pro quik для windows 11 скачать
  • Gnu privacy guard for windows