-
Notifications
You must be signed in to change notification settings - Fork 0
add AsOfType helper fn #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
cause_go118.go
Outdated
| } | ||
| } | ||
|
|
||
| func AsOfType[T error](err error) (T, bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IsOfType reads okay but AsOfType is a bit dense & grammatically weird, how about AsType?
| func AsOfType[T error](err error) (T, bool) { | |
| func AsType[T error](err error) (T, bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm torn, this is nice, but we already have a IsOfType and not IsType. In that case, I prefer to let consistency win here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency kinda fucks over grammar here, which is why I prefer AsType. IsOfType is valid cos it means the error is of a given type, IsType would be wrong because it's an error, not a type.
AsOfType just doesn't mean anything in English, so consistency will really hurt readability here imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, it won't have been the first time we mess with grammar in IT though 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely 😅
682336a to
83cd99b
Compare
cause_go118_test.go
Outdated
| } | ||
| } | ||
|
|
||
| func TestAsOfType(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
| func TestAsOfType(t *testing.T) { | |
| func TestAsType(t *testing.T) { |
83cd99b to
a4f2a9b
Compare
What does this PR do?
Add a new helper to
Aserrors without having to instanciate a variable beforehandGood PR checklist