Errors, goroutines and a complete program
Handling problems with errors, running work at the same time with goroutines and channels, and building a small command-line program.
About 4 hours of study
Learning objectives
- Return and check errors
- Use goroutines and channels safely
- Build a complete program from small parts
Lessons
- 1
Errors, panic and recover Intermediate
Go's way of handling problems: error values returned from functions, errors.New and fmt.Errorf, wrapping with %w, errors.Is and errors.As, custom error types, and panic with recover.
- 2
Goroutines and channels Intermediate
Running work at the same time with goroutines, passing values with channels, buffered channels, closing and ranging over a channel, waiting with sync.WaitGroup, protecting data with sync.Mutex and choosing with select.
- 3
Putting it together: a command-line program Intermediate
Designing and writing a small complete Go program from commands read on the input, using structs, methods, maps, slices, errors and a command loop.
Module practice
- Go: Safe divisionEasy
- Go: Parse numbers with errorsMedium
- Go: A stack machine with errorsHard
- Go: Sum in two halvesEasy
- Go: A pool of workersMedium
- Go: A three-stage pipelineHard
- Go: A calculator with commandsEasy
- Go: A task listMedium
- Go: A small libraryHard