Get the latest tech news

Discussion: Reduce error handling boilerplate in Golang using '?'


This is a discussion about a new syntax that may be used to handle errors. This is issue #71203 converted into a discussion. I've written a tool that converts ordinary Go code into code that uses t...

The goal of this proposal is to introduce a new syntax that reduces the amount of code required to check errors in the normal case, without obscuring flow of control. Since the main goal of this proposal is to reduce boilerplate, I believe that we should try our best to do just that, and introduce err in the scope rather than requiring people to declare it explicitly. However, it may not be too bad: Todd Kulesza did a user study and discovered that people unfamiliar with the syntax were able to see that the code had to do with error handling.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Discussion

Discussion

Photo of golang

golang

Related news:

News photo

How we centralized and structured error handling in Golang

News photo

Go Production Performance Gotcha – GOMAXPROCS

News photo

Lies we tell ourselves to keep using Golang (2022)