Basic Golang ( Getting Started )

How to install and start simple project


  • On MacOS
$ brew install golang
  • Setup Path
$ vi ~/.bash_profile

...
export GOROOT=/usr/local/Cellar/go/1.13.7/libexec
export GOPATH={path_destination}
export PATH=$PATH:/usr/local/go/bin
...

Example Start project go

  • Create Project
$ mkdir golang
$ cd golang
  • Create file main.go
package main

import "fmt"

func main() {
	fmt.Printf("What's up ? , GO \n")
}

  • Run
$ go run main.go
What's up ? , GO 
  • Build & Run
$ go build main.go
$ ./main.go
What's up ? , GO

ref :

Getting Started - The Go Programming Language