Set up Go


title: “Set up Go”
date: 2018-01-22T19:51:53
slug: settun-go-variables


Download the archive (https://golang.org/dl/)

and extract it into /usr/local, creating a Go tree in /usr/local/go. For example:

tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
export PATH=$PATH:/usr/local/go/bin

Create your workspace directory, $HOME/go. (If you’d like to use a different directory, you will need to set the GOPATH environment variable.)

mkdir -p $HOME/go/src

Create Test Project

mkdir $HOME/go/src/hello
vi $HOME/go/src/hello/hello.go
package main
import "fmt"
func main() {
fmt.Printf("hello, world
")
}

Then build it with the go tool:

cd $HOME/go/src/hello
go build

&

Print Friendly, PDF & Email