Go Installation
Go Language Installation
INSTALLATION DETAILS FOR ALL OPERATING SYSTEMS
Download Go Installable file:
Download the latest version of Go installable fileaccording to your operating system from the official site..
NOTE : Go language can be installed only on 64 bit operating systems
Installation on UNIX/Linux/Mac OS X and FreeBSD
Extract the downloaded archive into the folder /usr/local, creating a Go tree in /usr/local/go. For example: tar –C/usr/local –xzf go 1.4.linux-amd64.tar.gz. Add /usr/local/go/bin to the PATH environment variable.
Use the MSI file and follow the prompts to install the Go tools. By default, the installer uses the Go distribution in C:\Go. The installer should set the C:\Go\bindirectory in Window's PATH environment variable. Restart any open command prompts for the change to take effect.
Verify Go Installation and Configuration Open Command Prompt and execute the command “go version “to verify go installation.
Execute the command “go env “to verify go configuration. GOPATH should point to the workspace.
To checkwhether the installation is successful or not. We can write a simple Hello World program and execute it.
We can use any text editors like Notepad, Notepad++,Brief, Epsilon, EMACS, vim or vi etc. However, there are several limitations in plain text editors. We can use tools like Visual Studio Code for rapid code development.
The files contain program source code are calledGo program source files and are typically named with the extension “.go”.Create a go file named “test.go”in C:>Go_WorkSpace.
CODE/PROGRAM/EXAMPLE
package main
import "fmt"
func main(){
fmt.Println("Hello, World!")
}
Open a command prompt/terminal and execute the command run “test.go”to see the result
Syntax
C:\Go_WorkSpace>go run test.go
Output : Hello, World!