Go/Golang Cheat Sheet

Cheat sheet and tricks for the Go programming language.

Documentation

Installation

GOPATH support will drop in Go 1.17 and will also ignore GO111MODULE.

sudo apt install golang
#export PATH=$PATH:/usr/local/go/bin

Version

go version

Examples

hello.go

package main
import "fmt"
func main() {
    fmt.Println("Hello World!")
}
go run hello.go

Build & Execute

Will generate hello (Linux) or hello.exe (Windows)

go build hello.go
./hello