[ Level 1 ] Go installation and "Hello World" sample.

A friend of mine told me, if you could choose the programming language, choose the fashion one. I tried to use Go becuase it's "Go fashion"(Chinglish, means, fashion enough). The following script is the way to install Go in CentOS, you could refer to it if you also used CentOS.
#!/bin/bash 
# install Go, gcc for Go
rpm -q golang >/dev/null 2>&1 || sudo yum -y install golang libgo gcc-go

# Hello World
[ -e ./HelloWorld.go ] || cat > ./HelloWorld.go <<EOF
package main
import "fmt"
func main() {
  fmt.Println("Hellow World!")
}
EOF

# run as interpreter script
go run ./HelloWorld.go

# compile script and run it.
gccgo -g -o ./HelloWorld.out ./HelloWorld.go && ./HelloWorld.out


Wish this helps.

regards,
Stanley Huang

Comments

Popular posts from this blog

[Level 2] Shell Interactive With Zenity Episode 5 -- list

[Level 2] iif in Python