Error handling for Go 2

By Marcel van Lohuizen

Elevator Pitch

This talk discusses possible error handling improvements for Go 2. The first focus is semantics. I show some particularly tricky cases in Go 1 and how the issues can be mitigated using a package that introduces better semantics. We conclude with some possible directions for Go 2 under consideration.

Description

The goal of this talk is to involve the community in the rethinking of error handling for Go 2.

We first demonstrate why it is important to focus on semantics. We demonstrate a simulator of error scenarios where a developer is challenged to write correct code. A new package is introduced that helps solving the simulation puzzles. The purpose of this package is to shape the way we think about error handling in Go 2.

Next we show some proposals for language support in Go 2 to improve error handling based on the principles from the package, which stay true to the “error is a value” concept of Go errors.

We conclude with a broader picture of errors in Go.

Notes

I estimate that about a quarter of this talk will be a life demonstration.

Why I’m the best person to speak on this topic: I’m tasked by the Go team to rethink error handling for Go 2 and as such have a reasonable idea of what is going on. I’m also the writer of all both the simulator and the errd and errc error handling packages.