Skip to content

x/tools/gopls: modernize should simplify func calls which always return nil errors now #75064

@mvdan

Description

@mvdan

For example, as of Go 1.24, https://pkg.go.dev/crypto/rand#Read always returns a nil error on all platforms, so any callers like

_, err := rand.Read(b[:])
if err != nil {
        return nil, err
}

can be modernized and simplified to just

rand.Read(b[:])

I'm sure there are other instances where standard library APIs can never fail. Another one that comes to mind is the various io.Reader and io.Writer methods on bytes.Buffer, or some of the methods on strings.Builder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions