Skip to content
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

fix unwrap on typed nil #42

Merged
merged 1 commit into from
Jul 4, 2023
Merged

fix unwrap on typed nil #42

merged 1 commit into from
Jul 4, 2023

Conversation

isopov
Copy link
Contributor

@isopov isopov commented Jul 3, 2023

It seems that I have some typed as *errorx.Error nil and cannot debug its source - maybe we can ignore it instead of throwing NPD and it will manifest in a more readable way somewhere else?

@isopov isopov requested a review from PeterIvanov July 3, 2023 16:22
// %s simple message output
// %v same as %s
// %+v full output complete with a stack trace
// %s simple message output
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest go reformats comments this way - can I leave it this way? Other contributors most likely will use modern go as well.

Copy link
Collaborator

@PeterIvanov PeterIvanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any particular codebase, I'd rather fix the bad calls to Unwrap or find where the typed nil is returned as a result (alas, I failed to find the relevant reference, it must be in Effective Go or similar article).
But for a library, this seems like a good patch.

@isopov isopov merged commit a1c187a into master Jul 4, 2023
11 checks passed
@isopov isopov deleted the fix-unwrapped-on-typed-nil branch July 4, 2023 08:18
@PeterIvanov
Copy link
Collaborator

@isopov friendly colleague pointed to this: https://go.dev/doc/faq#nil_error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants