You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would you consider yourself a novice, intermediate, or experienced Go programmer?
Experienced.
What other languages do you have experience with?
Java, Groovy, Python, Erlang, Ruby, Delphi, FoxPro, C/C++, and others.
Would this change make Go easier or harder to learn, and why?
Neither. No language changes are included in this proposal.
Has this idea, or one like it, been proposed before?
Not that I am aware of.
What is the proposed change?
Simply say, in documentation and training materials (e.g. "Effective Go", "Go Style Best Practices"), that panic/recover is as acceptable as returning errors.
package db
...
func GetUserById(id string) User {
user := ...
if user == nil {
panic(fmt.Errorf("user not found: %s", id))
}
What is the cost of this proposal?
Minimal. Only documentation and training materials would need to be updated.
Can you describe a possible implementation?
N/A
How would the language spec change?
N/A
Orthogonality: how does this change interact or overlap with existing features?
N/A
Is the goal of this change a performance improvement?
No.
Does this affect error handling?
In the language, no. In solutions, perhaps.
*Is this about generics?
No.
Conclusion:
Panic and recover are features of the language. There is no reason that using them should be any less valid than using any other language feature. Making panic/recover as acceptable as returning errors would make error handling a less contentious subject and greatly reduce the desire of many programmers to "fix" it (or to just stop using Go).
The text was updated successfully, but these errors were encountered:
Proposal Details
Would you consider yourself a novice, intermediate, or experienced Go programmer?
Experienced.
What other languages do you have experience with?
Java, Groovy, Python, Erlang, Ruby, Delphi, FoxPro, C/C++, and others.
Would this change make Go easier or harder to learn, and why?
Neither. No language changes are included in this proposal.
Has this idea, or one like it, been proposed before?
Not that I am aware of.
What is the proposed change?
Simply say, in documentation and training materials (e.g. "Effective Go", "Go Style Best Practices"), that panic/recover is as acceptable as returning errors.
Is this change backward compatible?
Yes. No language changes are required.
Examples:
Idiomatic / good style:
Also idiomatic / good style:
What is the cost of this proposal?
Minimal. Only documentation and training materials would need to be updated.
Can you describe a possible implementation?
N/A
How would the language spec change?
N/A
Orthogonality: how does this change interact or overlap with existing features?
N/A
Is the goal of this change a performance improvement?
No.
Does this affect error handling?
In the language, no. In solutions, perhaps.
*Is this about generics?
No.
Conclusion:
Panic and recover are features of the language. There is no reason that using them should be any less valid than using any other language feature. Making panic/recover as acceptable as returning errors would make error handling a less contentious subject and greatly reduce the desire of many programmers to "fix" it (or to just stop using Go).
The text was updated successfully, but these errors were encountered: