Table of Contents

Resources

GoLang Docs - GoLang Tutorials

https://golang.org/ref/spec

Learn to Code - for Free | Codecademy

A Tour of Go

Learn to become a Go developer

Primer

This is my summary of the Golang basics. There is always a block of code and below it some bullet-points describing what it does + notable things that might be unique to Golang. I go from general to more specific / complex here, therefore, it might be useful to read through everything top to bottom if you are completely new to Golang, like me.

Basics

// define a file to be executable
package main

// import packages
import "fmt"

// declare a function
func main () {
  fmt.Println("Hello World!")
}
// do multiple imports like his
import "fmt"
import "time"

// OR
import (
	"fmt"
	t "time" // the 't' will be the shorthand for the package
)
# run files without compiling
go run main.go

# compile go scirpts
go build main.go

# execute binary
./main
# search the go docs like this
go doc fmt
# search for specific function
go doc time.Now