You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since err is commonly used, it's not uncommon to have it reassigned
If someone forgets to check it before reassigning it, G104 should catch it
Steps to reproduce the behavior
package main
import (
"io""log""os"
)
funcmain() {
_, _=io.WriteString(os.Stdout, "Hello World") // # this is ok_, err:=io.WriteString(os.Stdout, "Hello World")
iferr!=nil { // goodlog.Fatal(err)
}
_, err=io.WriteString(os.Stdout, "Hello World") // # this err will not be checked_, err=io.WriteString(os.Stdout, "Hello World") // # this err will be checkediferr!=nil { // checking the second err but not the first onelog.Fatal(err)
}
}
gosec version
2.14.0
Go version (output of 'go version')
go version go1.19.2
Operating system / Environment
darwin/arm64
Expected behavior
Should catch the err that wasn't checked
Actual behavior
Doesn't.
The text was updated successfully, but these errors were encountered:
Summary
Since
err
is commonly used, it's not uncommon to have it reassignedIf someone forgets to check it before reassigning it, G104 should catch it
Steps to reproduce the behavior
gosec version
2.14.0
Go version (output of 'go version')
go version go1.19.2
Operating system / Environment
darwin/arm64
Expected behavior
Should catch the
err
that wasn't checkedActual behavior
Doesn't.
The text was updated successfully, but these errors were encountered: