How to install golang windows

Install Golang on Windows 10 x64

Sep 29, 2019 · 3 min read

You can code and create applications with Go on any operation system.

In this manual I`ll show you how to setup Golang compiler for development on Windows 10 x64 in a few steps.

Golang tools (“go get”) use Git to download libs and manage their versions. Download git tools here: https://git-scm.com/download/win

Follow instructions in installer to complete Git setup.

Now you can install Golang compiler for Windows 10. To do that you need to download installer first. Follow the link and download the one for Windows: https://golang.org/dl/

Run downloaded file and complete installation following instructions in the installer.

Check Golang compiler is installed

  1. Open windows command prompt: press Win+R and enter cmd

2. Type “go version” and press Enter. This command will response with current go version installed, it means that go tools work fine and we shall go to creation of GOPATH environment variable.

Adding GOPATH environment variable

Usually Golang compiler and set of Go tools are being installed in C:\Go folder. When you update compiler, the content of this folder may be deleted. So this folder is not the right place to store you projects or dependencies. By creating GOPATH variable we tell Go tools to store all dependencies in specified folder.

To create GOPATH variable follow this simple steps:

  1. Open Explorer (Win+E) and create folder “C:\Projects\Go”

2. Open environment variables manager by pressing Win + R and enter “sysdm.cpl ,3” (pay attention to space before comma)

3. Then press “Environmental Variables” button on bottom right. It will require you to have admin rights.

4. Now you see two lists of environment variables. The upper list is your current user variables. The bottom one — system variables, applied for all users. Press “New” button below bottom list

5. Enter “GOPATH” as name and “C:\Projects\Go” as value and press Ok.

Download and install

Download and install Go quickly with the steps described here.

For other content on installing, you might be interested in:

  • Managing Go installations — How to install multiple versions and uninstall.
  • Installing Go from source — How to check out the sources, build them on your own machine, and run them.

1. Go download.

Click the button below to download the Go installer.

Don’t see your operating system here? Try one of the other downloads.

2. Go install.

Select the tab for your computer’s operating system below, then follow its installation instructions.

  1. Extract the archive you downloaded into /usr/local, creating a Go tree in /usr/local/go.

Important: This step will remove a previous installation at /usr/local/go, if any, prior to extracting. Please back up any data before proceeding.

For example, run the following as root or through sudo :

rm -rf /usr/local/go && tar -C /usr/local -xzf go1.14.3.linux-amd64.tar.gz

Add /usr/local/go/bin to the PATH environment variable.

You can do this by adding the following line to your $HOME/.profile or /etc/profile (for a system-wide installation):

Note: Changes made to a profile file may not apply until the next time you log into your computer. To apply the changes immediately, just run the shell commands directly or execute them from the profile using a command such as source $HOME/.profile .

Читайте также:  Какая сборка linux лучше

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.
    1. Open the package file you downloaded and follow the prompts to install Go.

    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.
    1. 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 needed. 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 at the command prompt.

  • Verify that you’ve installed Go.
    1. In Windows, click the Start menu.
    2. In the menu’s search box, type cmd , then press the Enter key.
    3. In the Command Prompt window that appears, type the following command:
  • Confirm that the command prints the installed version of Go.
  • 3. Go code.

    You’re set up! Visit the Getting Started tutorial to write some simple Go code. It takes about 10 minutes to complete.

    Managing Go installations

    This topic describes how to install multiple versions of Go on the same machine, as well as how to uninstall Go.

    For other content on installing, you might be interested in:

    • Download and install — The simplest way to get installed and running.
    • Installing Go from source — How to check out the sources, build them on your own machine, and run them.

    Installing multiple Go versions

    You can install multiple Go versions on the same machine. For example, you might want to test your code on multiple Go versions. For a list of versions you can install this way, see the download page.

    Note: To install using the method described here, you’ll need to have git installed.

    To install additional Go versions, run the go get command, specifying the download location of the version you want to install. The following example illustrates with version 1.10.7:

    To run go commands with the newly-downloaded version, append the version number to the go command, as follows:

    When you have multiple versions installed, you can discover where each is installed, look at the version’s GOROOT value. For example, run a command such as the following:

    To uninstall a downloaded version, just remove the directory specified by its GOROOT environment variable and the goX.Y.Z binary.

    Uninstalling Go

    You can remove Go from your system using the steps described in this topic.

    Linux / macOS / FreeBSD

    This is usually /usr/local/go.

    Remove the Go bin directory from your PATH environment variable.

    Under Linux and FreeBSD, edit /etc/profile or $HOME/.profile. If you installed Go with the macOS package, remove the /etc/paths.d/go file.

    Windows

    The simplest way to remove Go is via Add/Remove Programs in the Windows control panel:

    1. In Control Panel, double-click Add/Remove Programs.
    2. In Add/Remove Programs, select Go Programming Language, click Uninstall, then follow the prompts.

    For removing Go with tools, you can also use the command line:

      Uninstall using the command line by running the following command:

    Note: Using this uninstall process for Windows will automatically remove windows environment variables created by the original installation.

    How to install golang windows

    Prerequisite: Introduction to Go Programming Language

    Before, we start with the process of Installing Golang on our System. We must have first-hand knowledge of What the Go Language is and what it actually does? Go is an open-source and statically typed programming language developed in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson at Google but launched in 2009. It is also known as the Golang and it supports the procedural programming language. It was initially developed to improve programming productivity of the large codebases, multicore, and networked machines.

    Читайте также:  Radeon звуковой драйвер windows 10

    Golang programs can be written on any plain text editor like notepad, notepad++ or anything of that sort. One can also use an online IDE for writing Golang codes or can even install one on their system to make it more feasible to write these codes. Using an IDE makes it easier to write Golang codes because IDEs provide a lot of features like intuitive code editor, debugger, compiler, etc.
    To begin with, writing Golang Codes and performing various intriguing and useful operations, one must have the Go language installed on their System. This can be done by following the step by step instructions provided below:

    How to check the Preinstalled Go Language Version?

    Before we begin with the installation of Go, it is good to check if it might be already installed on your System. To check if your device is preinstalled with Golang or not, just go to the Command line(For Windows, search for cmd in the Run dialog( + R).

    Now run the following command:

    If Golang is already installed, it will generate a message with all the details of the Golang’s version available, otherwise, if Golang is not installed then an error will arise stating Bad command or file name

    Downloading and Installing Go

    Before starting with the installation process, you need to download it. For that, all versions of Go for Windows are available on golang.org.

    Download the Golang according to your system architecture and follow the further instructions for the installation of Golang.

    Step 1: After downloading, unzip the downloaded archive file. After unzipping you will get a folder named go in the current directory.

    Step 2: Now copy and paste the extracted folder wherever you want to install this. Here we are installing in C drive.

    Step 3: Now set the environment variables. Right click on My PC and select Properties. Choose the Advanced System Settings from the left side and click on Environment Variables as shown in the below screenshots.

    Step 4: Click on Path from the system variables and then click Edit. Then Click New and then add the Path with bin directory where you have pasted the Go folder. Here we are editing the path C:\go\bin and click Ok as shown in the below screenshots.

    Step 5: Now create a new user variable which tells Go command where Golang libraries are present. For that click on New on User Variables as shown in the below screenshots.

    Now fill the Variable name as GOROOT and Variable value is the path of your Golang folder. So here Variable Value is C:\go\. After Filling click OK.

    After that Click Ok on Environment Variables and your setup is completed. Now Let’s check the Golang version by using the command go version on command prompt.

    After completing the installation process, any IDE or text editor can be used to write Golang Codes and Run them on the IDE or the Command prompt with the use of command:

    Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

    Golang

    Блог о языке программирования Go

    понедельник, 24 июня 2019 г.

    Установка Go

    Загрузите дистрибутив Go

    Официальные бинарный дистрибутивы доступны для операционных систем FreeBSD (версия 10-STABLE и выше), Linux, macOS (10.10 и выше) и Windows, а также 32-битных (386) и 64-битных (amd64) процессорных архитектур x86.

    Читайте также:  Itunes обновление для mac os

    Если бинарный дистрибутив недоступен для вашей комбинации операционной системы и архитектуры, попробуйте установить из исходного кода или установить gccgo вместо gc.

    Системные требования

    Бинарный дистрибутивы Go доступны для следующих поддерживаемых операционных систем и архитектур. Пожалуйста, убедитесь, что ваша система соответствует этим требованиям, прежде чем продолжить. Если вашей ОС или архитектуры нет в списке, вы можете установить ее из исходного кода или использовать вместо нее gccgo.

    Установите инструменты Go

    Если вы обновляете более старую версию Go, вы должны сначала удалить существующую версию.

    Tarboll’ы для Linux, macOS и FreeBSD

    Загрузите архив и распакуйте его в /usr/local, создав дерево Go в /usr/local/go. Например:

    Выберите файл архива, подходящий для вашей установки. Например, если вы устанавливаете Go версии 1.2.1 для 64-битной x86 в Linux, то нужный вам архив называется go1.2.1.linux-amd64.tar.gz.

    (Обычно эти команды должны запускаться от имени пользователя root или через sudo.)

    Добавьте /usr/local/go/bin в переменную окружения PATH. Вы можете сделать это, добавив эту строку в ваш /etc/profile (для общесистемной установки) или в $HOME/.profile:

    Примечание. Изменения, внесенные в файл профиля, могут не применяться до следующего входа в систему. Чтобы немедленно применить изменения, просто запустите команды оболочки напрямую или выполните их из профиля, используя команду, например source $HOME/.profile.

    Установщик пакета macOS

    Загрузите файл пакета, откройте его и следуйте инструкциям по установке инструментов Go. Пакет устанавливает дистрибутив Go в /usr/local/go.

    Пакет должен поместить каталог /usr/local/go/bin в переменную среды PATH. Вам может потребоваться перезапустить все открытые сеансы терминала, чтобы изменения вступили в силу.

    Windows

    Проект Go предоставляет два варианта установки для пользователей Windows (помимо установки из источника): zip-архив, в котором требуется установить некоторые переменные среды, и установщик MSI, который автоматически настраивает установку.

    Установщик MSI

    Откройте файл MSI и следуйте инструкциям по установке инструментов Go. По умолчанию установщик помещает дистрибутив Go в c:\Go.

    Установщик должен поместить каталог c:\Go\bin в переменную окружения PATH. Вам может потребоваться перезапустить любые открытые командные строки, чтобы изменения вступили в силу.

    Zip архив

    Загрузите zip-файл и распакуйте его в каталог по вашему выбору (предлагается c:\Go).

    Добавьте подкаталог bin вашего корневого каталога Go (например, c:\Go\bin) в переменную среды PATH.

    Установка переменных среды под Windows

    В Windows вы можете установить переменные среды с помощью кнопки «Переменные среды» на вкладке «Дополнительно» панели управления «Система». Некоторые версии Windows предоставляют эту панель управления через параметр «Дополнительные параметры системы» на панели управления «Система».

    Проверьте вашу установку

    Убедитесь, что Go установлен правильно, настроив рабочее пространство и собрав простую программу следующим образом.

    Создайте свой каталог рабочей области, $HOME/go. (Если вы хотите использовать другой каталог, вам нужно установить переменную среды GOPATH.)

    Затем создайте в вашей рабочей области каталог src/hello, и в этом каталоге создайте файл с именем hello.go, который выглядит следующим образом:

    Затем соберите его с помощью инструмента go:

    Команда выше создаст исполняемый файл с именем hello в каталоге вместе с вашим исходным кодом. Выполните его, чтобы увидеть приветствие:

    Если вы видите сообщение «hello, world», значит, ваша установка Go работает.

    Вы можете запустить go install, чтобы установить бинарный файл в каталог bin вашего рабочего пространства, или выполните команду go clean -i, чтобы удалить его.

    Установка дополнительных версий Go

    В некоторых случаях может быть полезным иметь несколько версий Go на одном компьютере, например, чтобы гарантировать, что тесты пакета пройдут на нескольких версиях Go. После установки одной версии Go вы можете установить другую (например, 1.10.7) следующим образом:

    Недавно загруженную версию можно использовать как go:

    Все версии Go, доступные с помощью этого метода, перечислены на странице загрузки. Вы можете узнать, где установлена каждая из этих дополнительных версий Go, взглянув на GOROOT; например, go1.10.7 env GOROOT. Чтобы удалить загруженную версию, просто удалите ее каталог GOROOT и бинарный файл goX.Y.Z.

    Удаление Go

    Чтобы удалить существующую установку Go из вашей системы, удалите каталог go. Обычно это /usr/local/go под Linux, macOS и FreeBSD или c:\Go под Windows.

    Оцените статью