proposal: Go2: error handling with #err suffix #67251
Labels
error-handling
Language & library change proposals that are about error handling.
LanguageChange
Suggested changes to the Go language
LanguageChangeReview
Discussed by language change review committee
Proposal
Proposal-FinalCommentPeriod
Milestone
Go Programming Experience
4 years
Other Languages Experience
C, C++, Java, Dart, zig, rust
Related Idea
Has this idea, or one like it, been proposed before?
yes issues/21161
Does this affect error handling? yes
Is this about generics? no
Is this change backward compatible? compatible
Proposal
scr: https://github.com/mainjzb/goerr
Make
#
as error symbol, I believe people can learn and understand it quickly. (Maybe other symbol replace it)#@
as handler error symbol. Help people read code and simplify code.I have read go/issues/21161
My imaging is something similar to that.
before
now
igmore
6 char more than other 4 char#@wrap
equal to#@wrap("io.Wirite err:")
, omit parameter make it easier for people to handle error instead of ignore error.MustXxx()
andXxx()
two sets api. Now we just need only one. Just likego
keyword, we no longer need sync and async functions.People should reduce the discussion of compilation details. Focusing on achieving agreement on lang style.
Method chaining
move error to suffix have other benefit that separate return value and error. now we can Method chaining. Some people dislike Method Chaining but I like it.
Is this change backward compatible?
No
Orthogonality: How does this change interact or overlap with existing features?
This is an orthogonal new feature that can be used not only for error handling, but also to reduce repetitive boilerplate in other cases.
Would this change make Go easier or harder to learn, and why?
Most language errors are more complex. Only by making people aware that this is complex can they pay attention to it
Cost Description
No response
Changes to Go ToolChain
All of them.
Performance Costs
Compile time: extra injection work. Run time cost: none.
Prototype
No
The text was updated successfully, but these errors were encountered: