Skip to content

Add a shorthand for AppendInvoke#65

Merged
sywhang merged 3 commits intouber-go:masterfrom
burdiyan:feat/append-func-shorthand
Sep 6, 2022
Merged

Add a shorthand for AppendInvoke#65
sywhang merged 3 commits intouber-go:masterfrom
burdiyan:feat/append-func-shorthand

Conversation

@burdiyan
Copy link
Copy Markdown
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
Copy Markdown

CLAassistant commented Sep 1, 2022

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link
Copy Markdown

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
Copy Markdown
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?

Comment thread error.go Outdated
Comment thread error.go Outdated
Comment thread error.go Outdated
@burdiyan burdiyan force-pushed the feat/append-func-shorthand branch from 23d7f37 to a2bdee3 Compare September 4, 2022 19:54
@burdiyan
Copy link
Copy Markdown
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
@burdiyan burdiyan force-pushed the feat/append-func-shorthand branch from a2bdee3 to e06fb97 Compare September 4, 2022 19:56
Copy link
Copy Markdown
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.

Comment thread error_test.go Outdated
@sywhang
Copy link
Copy Markdown
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.

3 participants