+6 votes
in Development by (1.5m points)

How to install Go on Windows (Golang)

1 Answer

+7 votes
by (725k points)
 
Best answer

Today we are going to talk about the steps we must follow to install Go on Windows . Go developers also refer to this programming language as Golang and remember that it was designed by Google around 2009, who is responsible for maintaining and improving the project.

image

The installation process is really simple, but we will still explain it step by step for users with less experience and we will even include a basic example of the type “Hello world” so that you have a very basic idea of ​​how to program with Go.

How to install Go on Windows (Golang).

First of all we go to the official website , where we will download the installation package for Windows in its latest version (1.6.2 at the time of writing this tutorial). This package has the extension .msi and we must choose between the package of 64bit (go1.6.2.windows-amd64.msi) or 32bit (go1.6.2.windows-386.msi) depending on our operating system.

Once we download the installer on our PC, we proceed to run it and the installation wizard appears on the screen. We leave all the options as they come by default and we click on the "Next" button until the installation process finishes.

As we use the automatic installer, it is responsible for adding the environment variables automatically , so if we open a terminal and execute the go command, the different options offered by the Go command line will appear on the screen.

Go is a tool for managing Go source code.
Usage:
go command [arguments]
...

If you have correctly followed the previous steps, you can already say that Go is installed in your system to perform your first example as we will explain below.

My first program in GO, "Hello World".

We will first need a text editor, the Windows block of notes can serve us perfectly for this simple example, although it is always advisable to use some text editor that facilitates the tasks, such as Sublime Text .

We create a new text file and paste the following lines of code:

package main
import "fmt"

func main(){
    fmt.Println("Hola Mundo")
}

We test.txt the file as test.txt and close the editor. Now we need to change the file extension from test.txt to test.go , but we cannot execute the code or compile it.

We open the Windows command console until we are located in the folder where the test.go file is test.go which in my case is C:\Users\VOZIDEA\Desktop\gotest\ and then run the go run test.go command and we will see that the phrase "Hello world" is shown on the screen.

If instead of executing the code we wanted to compile an executable file, the command we would use would be go build test.go and a file with executable test.exe would be generated in the folder of our project.

This is all, enjoy programming with Go.


Most popular questions within the last 20 days

...