Skip to content

proposal: cmd/vet: add check for using %q with integer types #72850

Open
@rittneje

Description

@rittneje

Proposal Details

#32479 added a go vet warning for string(i), because it has the surprising behavior of returning the character with that integer code, as opposed to doing what strconv.Itoa does.

There is another similar case, where someone uses the %q format verb like so:

fmt.Printf("%q", 123) // prints '{'

Consequently, it would be helpful if go vet also warned about using %q with an integer type that does not implement error, fmt.Stringer, or fmt.Formatter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AnalysisIssues related to static analysis (vet, x/tools/go/analysis)ProposalToolProposalIssues describing a requested change to a Go tool or command-line program.

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions