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

False positive for multiple return values #5

Closed
twpayne opened this issue Jan 5, 2022 · 3 comments · Fixed by #6
Closed

False positive for multiple return values #5

twpayne opened this issue Jan 5, 2022 · 3 comments · Fixed by #6

Comments

@twpayne
Copy link

twpayne commented Jan 5, 2022

Given the following code:

package main

type T struct {
    s string
}

func (t T) MarshalJSON() ([]byte, error) {
    return json.Marshal(t.s)
}

errchkjson reports the error:

t.go:8:5: Error return value of `encoding/json.Marshal` is not checked (errchkjson)
        return json.Marshal(t.s)

which is a false positive, as it is the caller's responsibility to check the return value from T.MarshalJSON.

@breml
Copy link
Owner

breml commented Jan 11, 2022

@twpayne Thanks for your bug report. In will look into this.

@breml
Copy link
Owner

breml commented Jan 12, 2022

@twpayne Do you mind to test your use case again with the version from PR #6?

@twpayne
Copy link
Author

twpayne commented Jan 12, 2022

I confirm that #6 fixes the bug, thank you :)

@breml breml closed this as completed in #6 Jan 16, 2022
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 a pull request may close this issue.

2 participants