go-vet

Fix go vet warnings

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

When & Why to Use This Skill

This Claude skill streamlines the Go development workflow by identifying and fixing common programming errors detected by 'go vet'. It acts as an automated static analysis assistant that catches suspicious constructs—such as Printf format mismatches, unreachable code, and improper mutex usage—ensuring higher code reliability and adherence to Go best practices.

Use Cases

  • Automated Error Correction: Automatically resolve 'go vet' warnings like unkeyed composite literals and Printf verb mismatches to maintain a clean codebase.
  • Preventing Runtime Panics: Identify and fix potential nil pointer dereferences and lost context variables before they cause production incidents.
  • Concurrency Safety: Detect and correct suspicious mutex usage, such as passing mutexes by value, to prevent deadlocks and race conditions.
  • Code Maintenance: Scan large Go projects (./...) to find and remove unreachable code, improving overall logic flow and maintainability.
namego-vet
descriptionFix go vet warnings

go vet

Built-in static analyzer that catches common mistakes.

Usage

go vet ./...
go vet ./pkg/...

Common Warnings

Printf Format Mismatch

// Bad
fmt.Printf("%d", "string")

// Good
fmt.Printf("%s", "string")

Unreachable Code

// Bad
return value
fmt.Println("never runs")

// Good
fmt.Println("runs")
return value

Composite Literal Uses Unkeyed Fields

// Bad
Person{"Alice", 30}

// Good
Person{Name: "Alice", Age: 30}

Nil Dereference

// Bad
var p *int
fmt.Println(*p)

// Good
if p != nil {
    fmt.Println(*p)
}

Suspicious Mutex Usage

// Bad - mutex copied
func process(mu sync.Mutex) {
    mu.Lock()
}

// Good - pass pointer
func process(mu *sync.Mutex) {
    mu.Lock()
}

Lost Context

// Bad
ctx := context.TODO()

// Good
ctx := context.Background()
// or accept ctx as parameter

Fix All Issues

go vet ./... 2>&1 | tee vet.log