Skip to content
Search

Staticcheck

lastmod 2026-01-21created 2025-11-0510 edits

Staticcheck is a state of the art linter for the Go programming language. Using static analysis, it finds bugs and performance issues, offers simplifications, and enforces style rules.

Tools

Install

go install honnef.co/go/tools/cmd/staticcheck@latest

Installed to $GOPATH/bin. Just run staticcheck from the command line.

Usage

Just pass the location of your Go files.

staticcheck ./cmd/edge/

If there is a problem, an error is printed like this:

cmd/edge/main.go:541:23: Printf format %s has arg #1 of wrong type int64 (SA5009)

run script example

To search subfolders recursively, enter something like ./lib/...:

#!/usr/bin/env bash

ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" || exit; pwd)

if ! command -v go &> /dev/null; then
    echo "Not found go command" 1>&2
    exit 1
fi

staticcheck \
    "$ROOT_DIR/lib/..." \
    "$ROOT_DIR/cmd/..."

Warnings

How to handle the errors and warnings that are printed.

wrong type for method ProtoReflect

See Protocol Buffers#wrong type for method ProtoReflect for details.

See also

Favorite site

author Zer0 sitemap