Radar · Go · Archive · Week 23 · Jun 2 – 8, 2025
On | No syntactic support for error handling
Nice to knowlanguage
- What changed
- The Go team plans around error handling support.
- Production impact
- The source does not say.
- Try it
- Read the blog post to understand the current discussion.
- Source
- go.dev/blog/error-syntax
Understand it, then run it
The Go team decided not to add any new syntax for handling errors. In Go you still write x, err := call() and then if err != nil { … }. This pattern is common, but it can make functions look long and noisy. The team tried several ideas—check, try, and a ? operator—but none gained enough support, so they stayed with the current style.
Run it now
// This program demonstrates the current error handling style in Go.
// It parses two strings as integers, prints their sum, and returns an error if parsing fails.
package main
import (
"fmt"
"strconv"
)
func printSum(a, b string) error {
x, err := strconv.Atoi(a)
if err != nil {
return err
}
y, err := strconv.Atoi(b)
if err != nil {
return err
}
fmt.Println("result:", x+y)
return nil
}
func main() {
if err := printSum("10", "20"); err != nil {
fmt.Println("error:", err)
}
}
What it printed when we ran it on Go 1.27.1
result: 30
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed