| name | staticcheck |
| description | Fix staticcheck issues |
staticcheck
Advanced static analyzer with comprehensive checks.
Install
go install honnef.co/go/tools/cmd/staticcheck@latest
Usage
staticcheck ./...
staticcheck -checks=all ./...
Common Issues
SA1019: Deprecated Function
ioutil.ReadFile("file.txt")
os.ReadFile("file.txt")
SA4006: Unused Value
value := compute()
value = other()
_ = compute()
value := other()
SA9003: Empty Branch
if err != nil {
}
if err != nil {
return err
}
S1002: Simplify Condition
if x == true {
return true
}
return x
ST1003: Naming Convention
func GetHTTPSUrl() string
func GetHTTPSURL() string
SA1006: Printf on os.Stderr
fmt.Printf("error: %v\n", err)
fmt.Fprintf(os.Stderr, "error: %v\n", err)
SA4010: Result Not Used
append(slice, item)
slice = append(slice, item)
Configuration
checks = ["all", "-ST1000"]