Here is how I managed to install GO on CentOS7, just copy/paste will work.

VERSION=1.8
curl -LO https://storage.googleapis.com/golang/go$VERSION.linux-amd64.tar.gz
tar -C /usr/local -xvzf go$VERSION.linux-amd64.tar.gz
mkdir -p ~/projects/{bin,pkg,src}
echo “export PATH=$PATH:/usr/local/go/bin” > /etc/profile.d/go.sh
cat << ‘EOF’ >> ~/.bashrc
export GOBIN=”$HOME/projects/bin”
export GOPATH=”$HOME/projects/src”
EOF
source /etc/profile && source ~/.bash_profile
reboot

First silly “Hello World”…

cat << ‘EOF’ >> ~/projects/src/helloworld.go
package main

import “fmt”

func main() {
fmt.Printf(“Hello, World!\n”)
}
EOF

go install $GOPATH/helloworld.go
$GOBIN/helloworld
Hello, World!

That’s all, folks! Happy GOing.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *