Sunday, May 28, 2017

hello golang

how to start golang on mac os.

1. install golang

% brew install go

2. coding

% cat go_work.go
package main
import "fmt"

func main() {
SayHello()
}

func SayHello() {
fmt.Println("Hello World for go lang")
}

3. execution

run without build
% go run go_work.go
Hello World for go lang
build and run
% go build go_work.go
% ./go_work
Hello World for go lang