Overview
Installation
brew install go
Configuration
Setup default workspace
mkdir ~/go
mkdir ~/go/src
Hello World Example
vi helloworld.go
package main import ( "fmt" ) func main(){ fmt.Println("Hello World") }
Run it
go run helloworld.go
Commands
Command | Description |
---|---|
go run <src.go> | Run some code |
go build | Compile the code. Outputs to local folder. Executable has folder as name. |
go install | Compiles and places the output in workspace/bin |
go env GOPATH | Outputs the default workspace folder |
References
Reference | URL |
---|---|
Learn Go in 12 Minutes | https://www.youtube.com/watch?v=C8LgvuEBraI |
Go Packages | https://golang.org/pkg/ |