golang

CentOS golang Installation Instructions – for CentOS 6.x.
In the following tutorial I’ll show how to and run “Hello, world!” script with golang on CentOS 6.x

 

CentOS golang Installation Instructions – for CentOS 6.x

Install EPEL

  install epel-release.noarch

Install golang

Simple as:

yum install golang

you may want to install hg also, you’ll probably will need it later for the ‘go get’ :

yum install hg

Hello, World!

create a file named ‘hello.go’ and fill it with:

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

run the script using:

go run hello.go

$GOPATH

The ‘Hello, World!’ is a very basic example, but in real-world you may need to install packages and libraries for more complex applications.

The $GOPATH environment variable specifies the location of your workspace. It is likely the only environment variable you’ll need to set when developing Go code.

If your project for example is located at $HOME/go, you should create a variable like:

export GOPATH=$HOME/go

For convenience, add the workspace’s bin subdirectory to your path:

export PATH=$PATH:$GOPATH/bin

Now, your project environment variables are set and you can packages with the simple command: (for example – the OAuth 2.0 library)

go get code.google.com/p/goauth2/oauth

 

What’s next

Web Applications using Go

Template Engines for Go

Web Applications in Production

Print Friendly, PDF & Email

Comments

comments

Bài viết liên quan