Saturday, April 18, 2020

How to install Golang in Linux

sudo apt-get update
sudo apt-get -y upgrade

cd /tmp
wget https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.14.2.linux-amd64.tar.gz

open ~/.profile and add below variable at the end
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

update current shell session
source ~/.profile

go version

write hello.go
package main

import "fmt"

func main() {
 fmt.Printf("hello, world\n")
}
build 
go build hello.go

run
./hello


No comments:

Post a Comment

free online comma separating tool

https://delim.co/#