Lesson 8 of 60
GoError Handling & Defer
20 minutes
Course progress13%
Errors in Go
This lesson explains the main concept clearly with beginner-friendly examples and background so you can learn why the code works.
Go does not have exceptions. Functions return an error value which must be checked.
func ReadFile(name string) ([]byte, error) {
os.ReadFile(name)
}
data, err := ReadFile()
err != {
log.Fatalf(, err)
}