Skip to content

x/tools/go/analysis/passes/printf: false positive breaks tests in package #69831

Closed as not planned
@mark-pictor-csec

Description

@mark-pictor-csec

Go version

go1.23, go1.22, tip

Output of go env in your module/workspace:

N/A (repro in playground)

What did you do?

I wrote a function which takes optional args of type any; if the first optional arg is of type string, it is passed to fmt.Sprintf as the format.

The vet check believes I'm incorrectly providing a format specifier; until I found a way to defeat the check, it prevented any tests within the package from running.

https://go.dev/play/p/b6AupyJEr6s

printf analyzer documentation is available on pkg.go.dev

What did you see happen?

The printf checker produces a false positive, and there doesn't seem to be a way to disable it. I was unable to run any tests in the affected package until I found a way to defeat the checker.

What did you expect to see?

go test and the playground compile and execute the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions