How to install Go programming language on debian 8.6

How to install Go programming language on debian 8.6

Go, is a modern, open-source programming language developed by Google. Increasingly popular for many applications, Go takes a minimalist approach to development and makes it easy to build reliable and efficient software. The installation process is explained as follows. 

 

Installation process

Now you should first download the Go tar file.

root@linuxhelp:~# curl -O https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 80.1M  100 80.1M    0     0  1115k      0  0:01:13  0:01:13 --:--:-- 1140k

Then extract the tar file.

root@linuxhelp:~# tar xvf go1.7.4.linux-amd64.tar.gz
go/
go/AUTHORS
go/CONTRIBUTING.md
go/CONTRIBUTORS
go/LICENSE
go/PATENTS
go/README.md
go/VERSION
go/api/
go/api/README
go/api/except.txt
go/api/go1.1.txt
go/api/go1.2.txt
go/api/go1.3.txt
go/api/go1.4.txt
go/api/go1.5.txt
go/api/go1.6.txt
go/api/go1.7.txt
.
.
.
go/test/uintptrescapes.dir/a.go
go/test/uintptrescapes.dir/main.go
go/test/uintptrescapes.go
go/test/uintptrescapes2.go
go/test/undef.go
go/test/utf.go
go/test/varerr.go
go/test/varinit.go
go/test/writebarrier.go
go/test/zerodivide.go

Now you can move the extracted directory to "/usr/local" directory.

root@linuxhelp:~# mv go /usr/local

Set environment variable path on profile file like below.

root@linuxhelp:~# nano ~/.profile

In profile settings, set the environment variables. Type the lines and save it.

export GOPATH=$HOME/work
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin

Now reload the profile file.

root@linuxhelp:~# source ~/.profile

Create directory for projects.

root@linuxhelp:~# mkdir $HOME/work

Then create project directory.

root@linuxhelp:~# mkdir -p work/src/my_project/hello

Create sample project execution file like below.

root@linuxhelp:~# nano ~/work/src/my_project/hello/hello.go

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

Next compile your project by using go install command.

root@linuxhelp:~# go install my_project/hello

Now run your project.

root@linuxhelp:~# hello
Hello, World!

Thank you! for using Linux Help.

You find this tutorial helpful? Share with your friends to keep it alive.
For more help topics browse our website www.linuxhelp.com
Be the first to comment, we value your suggestions. For further queries please comment below.

Tags: Go language
user image Author :  Benjamin