Skip to content

x/tools/gopls/internal/analysis/modernize: use strings.Cut #71369

@adonovan

Description

@adonovan

[Update: CutPrefix was done by https://go.dev/cl/655777; this issue is now about strings.Cut.]

Replace:

if strings.HasPrefix(s, pre) { use(strings.TrimPrefix(s, pre)) }
-> 
if after, ok := strings.CutPrefix(s, pre); ok { use(after) } 

Variants:

  • bytes package
  • CutSuffix
  • if rest := strings.TrimPrefix(s, pre); rest != s { use(rest) } -> ...

cc: @josharian

Metadata

Metadata

Assignees

Labels

FeatureRequestIssues asking for a new feature that does not need a proposal.RefactoringIssues related to refactoring toolsToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.help wanted

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions