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

Return value #92

Closed
wants to merge 2 commits into from
Closed

Return value #92

wants to merge 2 commits into from

Conversation

ehsansouri23
Copy link

One of my use cases was to retry a block of code that returns a value. so I opened this pull request also to return value if retrying was successful. otherwise return nil and error

@dillonstreator
Copy link
Contributor

This would be a breaking change and it's already possible to capture whatever arbitrary value(s) your retryable function may produce with native closure semantics.

var err error
var result interface{}

err = retry.Do(func() error {
  result, err = someFn()
  return err
})
if err != nil {}

// use result

This pattern is also shown in the readme https://github.com/avast/retry-go#synopsis

@JaSei
Copy link
Collaborator

JaSei commented Apr 21, 2023

I agree with @dillonstreator.
Please take a look at #91 if you find it valuable. Comments and concerns are welcome.

@JaSei JaSei closed this Apr 21, 2023
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