Closed as duplicate of#72035
Description
package main
import (
"sort"
)
func main() {
foo := []string{}
sort.Slice(foo, func(i, j int) bool { return foo[i] < foo[j] })
}
Running go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix ./...
on this yields:
package main
import (
"slices"
"sort"
)
func main() {
foo := []string{}
slices.Sort(foo)
}
Which is invalid go because of compile error "sort" imported and not used
. Instead, gopls should remove the unused sort
import.