Closed ThierrySMG closed 2 months ago
The diagnostic is correct, but a bit subtle.
Your code
for _, p := range r.refPathRes {
if ok, err := c(p, f); err != nil {
return &auxRsp{
err: err,
}
} else if !ok {
continue
}
}
is identical to
for _, p := range r.refPathRes {
if _, err := c(p, f); err != nil {
return &auxRsp{
err: err,
}
}
}
That is, the else
branch is entirely superfluous, as all it does is what would happen, anyway: the continuation of the loop.
Thanks for help ! Sorry for the false positive.
Output of the command and what's wrong with the output
Where we can read the code you're running Staticcheck on https://github.com/cortezaproject/corteza/blob/eb7c39fee5dabcd1a73b2822866cd86f5be2c0b8/server/pkg/envoy/store/system.go#L442C1-L443C1
**the code***
Note, I read the Go specification about portability of variable declared inside if and used in else if, I don't found something perfectly clear. I tried to reproduce the case without success. It seems the ok value is used. Note the function c could return all combination of (bool, err).
staticcheck -version
Note: I compile staticcheck from commit: 0a683c983d783468a36cacffe289440ea4b7b943
staticcheck -debug.version
go version
go env
Exactly which command you ran