How to run Go 1.5 on CentOS 7.

How to run Go 1.5 on CentOS 7.

In the previous post we installed Go on CentOS 7. There is an small problem by doing that, the latest version on the repos for Go is 1.4. In this post I will show how to install Go 1.5 using the binaries.

This is a manual procedure and there are other ways to achieve this.

Downloading binaries###

[root@master tmp]# wget https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz

Extract the binaries to /usr/local/go:

[root@master tmp]# tar -C /usr/local -xzf /tmp/go1.5.linux-amd64.tar.gz

Now we will create the We create symbolic links (you can also add /usr/local/go/ to your PATH):

[root@master tmp]# ln -s /usr/local/go/bin/go /usr/bin/go
[root@master tmp]# ln -s /usr/local/go/bin/go /usr/local/bin/go
[root@master tmp]# ln -s /usr/local/go/bin/godoc /usr/local/bin/godoc
[root@master tmp]# ln -s /usr/local/go/bin/gofmt /usr/local/bin/gofmt

Verify that Go v1.5 runs

Run go version to verify that the install worked and version is 1.5:

[root@master ~]# go version
go version go1.5 linux/amd64

Verify that code can run by creating a "hello world" program:

[root@master ~]# cat << EOF > hello.go
package main

import "fmt"
func main() {
fmt.Printf("hello world!\n")
}
EOF

Run it:

[root@master ~]# go run hello.go
hola, mundo

Now you have Go 1.5 running on your CentOS 7 OS.