Installing golang from sources

Pre requisites:
1. wget
2. sudo
3. tar

Steps:
# Get the source of golang 1.14.4 using wget
1. wget https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz

# The extracted folder is in /usr/local/go
2. sudo tar -C /usr/local -xzf go1.14.4.linux-amd64.tar.gz

# Setting up environment  variables
3. vim do_env_go.sh

#contents of the file do_env_go.sh
PATH=/usr/local/go/bin:${PATH}
PATH=${HOME}/go/bin:${PATH}

# Run do_env_go.sh to add the go paths to environment path
4. source do_env_go.sh

# check golang environment
5. go env

# write a hello.go, compile and run
Example: hello.go
//program start
package main

import "fmt"

func main () {
    fmt.Println("Hello, world")
} //program end

$ go run hello.go
Hello, world

Thank you.
Susarla Nikhilesh.

Reply via email to