This is a proposal for a way to simplify the error handling in Go.
The idea is to use attempt{}
and recover{}
blocks to separate the happy path from the error handling. NOTE: this is NOT exception handling as you would see in Java or PHP. More on why below.
In this proposal Go would allow the developer to omit capturing the last returned variable from a function call if and only if that call was within a attempt{}
block. The Go compiler would handle providing access to the error
instance via the geterror()
function within the recover{}
block if any function returns a non nil
error as its last omitted parameter, i.e.:
attempt{
data:= GetData()