Skip to content

proposal: recommend fmt.Errorf #259

@albertyw

Description

@albertyw

Go 1.26 has this in its changelog:

For unformatted strings, fmt.Errorf("x") now allocates less and generally matches the allocations for errors.New("x").

Source: https://go.dev/doc/go1.26#fmtpkgfmt

This probably requires some benchmarking, but should this mean https://github.com/uber-go/guide/blob/master/src/error-type.md should be updated to generally recommend fmt.Errorf for all cases for consistency instead of the current "use fmt.Errorf iff for dynamic error messages"?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions