Skip to content

simple: flag uses of strings.CutPrefix/CutSuffix that should use strings.TrimPrefix/TrimSuffix instead #1608

Open
@cespare

Description

Since the introduction of strings.CutPrefix and strings.CutSuffix I've started noticing code that should use strings.TrimPrefix/strings.TrimSuffix instead:

x, _ := strings.CutPrefix(y, "abc")

I just implemented the trivial analyzer for this for our internal lint tool. Might be a nice (tiny) addition to staticcheck.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions