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

Error return value is not checked (errcheck) for interface assertion #230

Open
seaguest opened this issue Mar 6, 2023 · 1 comment
Open
Labels

Comments

@seaguest
Copy link

seaguest commented Mar 6, 2023

Hello,


seaguest@DEV:~/Work/monitor/test$ golangci-lint version
golangci-lint has version 1.51.2 built from 3e8facb4 on 2023-02-19T21:43:54Z
seaguest@DEV:~/Work/monitor/test$ 
seaguest@DEV:~/Work/monitor/test$ 
seaguest@DEV:~/Work/monitor/test$ cat t4.go
package main

import (
    "errors"
)

var _ error = (*ValidationError)(nil)

type ValidationError struct {
    Msg string
}

func (v *ValidationError) Error() string {
    return v.Msg
}

func main() {
    foo("huu")
}

func foo(a string) error {
    if a == "a" {
        return errors.New("OOPS")
    }

    return nil
}
seaguest@DEV:~/Work/monitor/test$ golangci-lint run -Eerrcheck 
t4.go:7:5: Error return value is not checked (errcheck)
var _ error = (*ValidationError)(nil)
    ^
t4.go:18:5: Error return value is not checked (errcheck)
    foo("huu")
       ^

There should not be error for

var _ error = (*ValidationError)(nil)

It seems related to
#219

@kisielk kisielk added the bug label Mar 9, 2023
@meteorgan
Copy link
Contributor

This problem exists because errcheck doesn't recognize the value of type conversion. It only checks if the result value is error type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants