{

Learn Golang tutorials-Install and setup Windows


Learn an easy way to install go language on windows.

Golang installation on windows

Go Language installation

Go is a modern popular open-source programming language. Go language developed by Google. It provides binary versions for Windows, macOS, and Linux officially. If you want to install a different environment, You can get the source code and build it to your platform.
Go language provides the following binaries for installation in different environments.

  • Windows
  • Apple macOS
  • Linux
  • Ubuntu

Installation and Setup on Windows

First, get the binary installer for windows ie MSI file from and download it. It downloads the MSI file.

Once the download completes, Install the MSI file and select A:\Golang location to follow the next steps.

The next step is to configure environment variables.

Configure Environment Variables

Go to My Computers or This PC –> properties –> Advance System Settings –> Environment Variables, Create a System variable or environment variable GO_ROOT

give the value of GO_ROOT to A:\Golang folder

Next, configure GO_ROOT to PATH variable ie set PATH to %PATH%\%GO_ROOT%\binary

It installs the Go Language successfully.

Check Golang Installation

To check the installation, first Open a command-line shell and give the “go version” command, It gives the go language version correctly.

C:\>go version  
go version go1.11.2 windows/amd64  
  
C:\Users\Kiran>go env  
set GOARCH=amd64  
set GOBIN=  
set GOCACHE=C:\Users\Kiran\AppData\Local\go-build  
set GOEXE=.exe  
set GOFLAGS=  
set GOHOSTARCH=amd64  
set GOHOSTOS=windows  
set GOOS=windows  
set GOPATH=C:\Users\Kiran\go  
set GOPROXY=  
set GORACE=  
set GOROOT=A:\Golang  
set GOTMPDIR=  
set GOTOOLDIR=A:\Golang\pkg\tool\windows_amd64  
set GCCGO=gccgo  
set CC=gcc  
set CXX=g++  
set CGO_ENABLED=1  
set GOMOD=  
set CGO_CFLAGS=-g -O2  
set CGO_CPPFLAGS=  
set CGO_CXXFLAGS=-g -O2  
set CGO_FFLAGS=-g -O2  
set CGO_LDFLAGS=-g -O2  
set PKG_CONFIG=pkg-config  
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\Kiran\AppData\Local\Temp\go-build682765038=/tmp/go-build -gno-record-gcc-switches  

Create a First sample Program

using any IDE or editor, Write the first program and save this file as “First.go” package main

package main  
import "fmt"  
  
func main() {  
    fmt.Printf("Hello, World")  
}  

To compile the First.go file, Use the go build command.

  
A:\Golang\work>dir  
 Volume in drive A is Work  
 Volume Serial Number is C682-8F53  
  
 Directory of A:\Golang\work  
  
12-11-2018  14:54    <DIR>          .  
12-11-2018  14:54    <DIR>          ..  
12-11-2018  14:49                83 First.go  
               1 File(s)             83 bytes  
               2 Dir(s)  125,885,014,016 bytes free  
  
A:\Golang\work>go build First.go  
  
A:\Golang\work>dir  
 Volume in drive A is Work  
 Volume Serial Number is C682-8F53  
  
 Directory of A:\Golang\work  
  
12-11-2018  14:54    <DIR>          .  
12-11-2018  14:54    <DIR>          ..  
12-11-2018  14:54         1,969,152 First.exe  
12-11-2018  14:49                83 First.go  
               2 File(s)      1,969,235 bytes  
               2 Dir(s)  125,883,043,840 bytes free  
  
A:\Golang\work>  

Execute the First.exe file by the following command

A:\Golang\work>First.exe  
Hello World 
THE BEST NEWSLETTER ANYWHERE
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
Subscribe
You'll get a notification every time a post gets published here.