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

Add a shorthand for AppendInvoke #65

Merged
merged 3 commits into from Sep 6, 2022

Conversation

burdiyan
Copy link
Contributor

@burdiyan burdiyan commented Sep 1, 2022

I really like the idea of catching returned errors from deferred functions. Though having to use multierr package name twice in the same line makes it a bit verbose in many occasions.

This PR introduces a shorthand for AppendInvoke which allows passing function or method value directly without wrapping it into an Invoker.

So this:

defer multierr.AppendInvoke(&err, multierr.Invoke(my.StopFunc))

could become this:

defer multierr.AppendFunc(&err, my.StopFunc)

@CLAassistant
Copy link

CLAassistant commented Sep 1, 2022

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Sep 1, 2022

Codecov Report

Merging #65 (d260cb7) into master (80b07a7) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master       #65   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines          108       109    +1     
=========================================
+ Hits           108       109    +1     
Impacted Files Coverage Δ
error.go 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@sywhang sywhang left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution! This seems like a valid API to add to multierr. I left a couple of suggestions re: the doc. Can you please also add some test cases that covers this?

error.go Outdated Show resolved Hide resolved
error.go Outdated Show resolved Hide resolved
error.go Outdated Show resolved Hide resolved
@burdiyan
Copy link
Contributor Author

burdiyan commented Sep 4, 2022

Applied suggestion docs changes. Added a test for the function. Let me know if you see other things to improve.

Co-authored-by: Sung Yoon Whang <sungyoonwhang@gmail.com>

Apply code review suggestions

Co-authored-by: Sung Yoon Whang <sungyoonwhang@gmail.com>

Adding tests
Copy link
Contributor

@sywhang sywhang left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes. LGTM.

error_test.go Outdated Show resolved Hide resolved
@sywhang
Copy link
Contributor

sywhang commented Sep 5, 2022

@abhinav do you know why the build is stuck here?

@sywhang sywhang merged commit 4459990 into uber-go:master Sep 6, 2022
@burdiyan burdiyan deleted the feat/append-func-shorthand branch September 7, 2022 10:34
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

3 participants