staticcheck

Fix staticcheck issues

⭐2stars🔀0forks📁View on GitHub🕐Updated Dec 28, 2025

When & Why to Use This Skill

This Claude skill integrates the powerful 'staticcheck' analyzer to automatically detect and resolve a wide range of issues in Go source code. It helps developers maintain high code quality by identifying bugs, performance bottlenecks, deprecated API usage, and stylistic inconsistencies, effectively acting as an automated code reviewer to ensure idiomatic and efficient Go development.

Use Cases

  • Automated Code Auditing: Scan Go projects to identify hidden bugs, logic errors, and empty branches that standard compilers might overlook.
  • Legacy Code Refactoring: Automatically detect and replace deprecated functions (e.g., migrating from ioutil to os) to keep the codebase modern and maintainable.
  • Performance Optimization: Identify unused values, ineffective assignments, and suboptimal code patterns that impact execution efficiency.
  • Style and Convention Enforcement: Ensure the codebase adheres to Go community standards for naming conventions and simplified conditional logic for better readability.
namestaticcheck
descriptionFix 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

// Bad
ioutil.ReadFile("file.txt")

// Good
os.ReadFile("file.txt")

SA4006: Unused Value

// Bad
value := compute()
value = other()

// Good
_ = compute()
value := other()

SA9003: Empty Branch

// Bad
if err != nil {
    // TODO
}

// Good - remove or implement
if err != nil {
    return err
}

S1002: Simplify Condition

// Bad
if x == true {
    return true
}

// Good
return x

ST1003: Naming Convention

// Bad
func GetHTTPSUrl() string

// Good
func GetHTTPSURL() string

SA1006: Printf on os.Stderr

// Bad
fmt.Printf("error: %v\n", err)

// Good
fmt.Fprintf(os.Stderr, "error: %v\n", err)

SA4010: Result Not Used

// Bad
append(slice, item)

// Good
slice = append(slice, item)

Configuration

# .staticcheck.conf
checks = ["all", "-ST1000"]