Replies: 2 comments 6 replies
-
Hello, golangci-lint is a wrapper around linters, so the rules are related to linter like errcheck not to golangci-lint itself. In all cases, I'm not able to reproduce your problem, so I think you have another problem. 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
} $ golangci-lint version
golangci-lint has version 1.51.2 built from 3e8facb4 on 2023-02-19T21:43:54Z
$ golangci-lint run -Eerrcheck
foo.go:18:5: Error return value is not checked (errcheck)
foo("huu")
^ |
Beta Was this translation helpful? Give feedback.
0 replies
-
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")
^ |
Beta Was this translation helpful? Give feedback.
6 replies
Answer selected by
ldez
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
The following code pass golangci-lint 1.48.0, but failed in 1.51.2
so what is the encouraged way to check if a struct implement the interface?
thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions