Skip to content

vet: fmt.Errorf("ordinary string") should be replaced by errors.New("ordinary string") #17173

@kevinburke

Description

@kevinburke

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

1.7.1

What operating system and processor architecture are you using (go env)?

All

What did you do?

Vet this program: https://play.golang.org/p/krp8cxL_Lv

package main

import "fmt"

func main() {
    err := fmt.Errorf("ordinary error")
    fmt.Printf("%#v\n", err)
}

What did you expect to see?

fmt.Errorf("an ordinary string") - with no formatting arguments - should be replaced by errors.New("an ordinary string"), to avoid the overhead of calling errors.New(Sprintf(...)).

What did you see instead?

No warning.

I'm happy to try to provide a patch here, if this is of interest.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions