-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
RefactoringIssues related to refactoring toolsIssues related to refactoring toolsToolProposalIssues describing a requested change to a Go tool or command-line program.Issues describing a requested change to a Go tool or command-line program.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.help wanted
Milestone
Description
I ran modernize
on typescript-go
, which caught this code:
if str := strings.TrimPrefix(msg, "Found 'package.json' at '"); str != msg {
// ...
}
And correctly turned it into:
if str, ok := strings.CutPrefix(msg, "Found 'package.json' at '"); ok {
// ...
}
But, right above this code was this:
if str := strings.TrimSuffix(msg, "' does not exist."); str != msg {
// ...
}
That is, the same pattern, but with a suffix. This did not get modernized.
Based on https://github.com/golang/tools/blob/master/gopls/internal/analysis/modernize/stringscutprefix.go (especially its name), it looks as though these modernizations only apply to prefixes, not suffixes. It'd be great to have it in both directions, since the transformation seems about the same?
adonovan, kwjw, AlexsanderHamir and cuishuang
Metadata
Metadata
Assignees
Labels
RefactoringIssues related to refactoring toolsIssues related to refactoring toolsToolProposalIssues describing a requested change to a Go tool or command-line program.Issues describing a requested change to a Go tool or command-line program.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.help wanted