Notes for some presentations on Go to beginners.
if err := json.NewEncoder(w).Encode(todos); err != nil {
panic(err)
}
or
js := []byte{}
js, err = json.Marshal(currentBox)
if err != nil {
panic(err)
}
- Slices
- make/delete/new function
- Variadic function
- takes zero or more parameters in args
- unpacking slices/array into Variadic functions
- callFunction(sliceName...)
- Closures - function declaration inside function
- Defer, panic, and recover
- Garbage collected
- Struct methods, and receivers
- Embedded Types, and anonymous fields
- Interfaces, and “method set[s]”
- Concurrency, and Goroutines and channels
- Select (like switch) statement for channel
- Buffered Channels
- Error Handling in Go is IMPORTANT
- Error type
- Declaring your own type
type Fame []int
- Interfaces, and “method set[s]”