proposal: Go 2: errors handling #63380
Labels
error-handling
Language & library change proposals that are about error handling.
FrozenDueToAge
LanguageChange
Suggested changes to the Go language
Proposal
v2
An incompatible library change
Milestone
Author background
Proposal
I think Go can add some syntax sugar that make the error handling easier. Developer can mark an error with a marker/operator and if this marked error is not 'nil' it's value will be returned.
Example
'''go
err! := example.ShouldRetErr()
'''
The '!' operator will simulates checking the err value and returning it if it's not 'nil' (maybe replace it with if statement behind-the-scenes) and we don't need to rewrite the if statement every time we get an error as a return.
The if statement errors handling still doable which guarantees backward compatibility.
The text was updated successfully, but these errors were encountered: