Custom Search

Tuesday, May 16, 2017

How to install latest Go Compiler on GNU/Linux

a)
Download Go compiler from https://golang.org/dl/

b)
Extract it ($HOME/golang_tuto/)

c)
Create a new directory for your go project ($HOME/golang_tuto/mygo)



d)
Add the following lines to your $HOME/.bashrc
export GOROOT=$HOME/golang_tuto/go
export PATH=$GOROOT/bin:$PATH

export GOPATH=$HOME/golang_tuto/mygo
export PATH=$GOPATH/bin:$PATH

e)
$go help


f)
$vim hello.go

package main

import "fmt"

func main() {
    fmt.Println("Hello World")
}

g)
$go build hello.go
$./hello

OR

$go run hello.go

No comments:

Post a Comment