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

Simplify error handling in golang snippets #158

Closed
wants to merge 40 commits into from

Conversation

ok300
Copy link
Contributor

@ok300 ok300 commented Apr 29, 2024

As discussed in #122 (comment) , this PR updates the error handling in golang snippets.

@ok300
Copy link
Contributor Author

ok300 commented Apr 29, 2024

@JssDWt is this what you had in mind?

@ok300 ok300 force-pushed the ok300-simplify-golang-error-handling branch from bf86feb to b4486af Compare April 30, 2024 13:01
@dangeross
Copy link
Contributor

For the functions where an err is returned, you need to add the return type to the function and return nil otherwise e.g.

func DoSomething() error {
    res, err := DoIt()
    if err != nil {
        return err
    }
    return nil
}

or if there is already a return type:

func DoThing() (*Thing, error) {
    ...
    if err != nil {
        return nil, err
    }
    ...
    return thing, nil
}

@JssDWt
Copy link
Contributor

JssDWt commented May 3, 2024

@JssDWt is this what you had in mind?

That's exactly what I had in mind!

Base automatically changed from ok300-add-channel-open-fees-receive-payment to pre-release September 8, 2024 07:27
@JssDWt
Copy link
Contributor

JssDWt commented Jan 10, 2025

Replaced by #183 because it was easier to recreate than to fix the conflicts.

@JssDWt JssDWt closed this Jan 10, 2025
@ok300 ok300 deleted the ok300-simplify-golang-error-handling branch January 10, 2025 15:46
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