mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-17 20:00:07 +00:00
Use slices.Sort instead of sort.Slice.
There were only two instances of this in the entire code-base. Hence, I have enabled the modernize rule/linter in golangci-lint.
This commit is contained in:
@@ -597,14 +597,6 @@ linters:
|
||||
# A useful hint because it can make code more obvious
|
||||
# and/or avoid helper functions.
|
||||
- slicescontains
|
||||
# Replace sort.Slice with slices.Sort for basic types.
|
||||
#
|
||||
# A useful hint because the code becomes shorter.
|
||||
- slicessort
|
||||
# Use iterators instead of Len/At-style APIs.
|
||||
#
|
||||
# A useful hint because the code becomes shorter.
|
||||
- stditerators
|
||||
# Replace HasPrefix/TrimPrefix with CutPrefix.
|
||||
#
|
||||
# A useful hint because the code becomes shorter.
|
||||
|
||||
@@ -333,14 +333,6 @@ linters:
|
||||
# A useful hint because it can make code more obvious
|
||||
# and/or avoid helper functions.
|
||||
- slicescontains
|
||||
# Replace sort.Slice with slices.Sort for basic types.
|
||||
#
|
||||
# A useful hint because the code becomes shorter.
|
||||
- slicessort
|
||||
# Use iterators instead of Len/At-style APIs.
|
||||
#
|
||||
# A useful hint because the code becomes shorter.
|
||||
- stditerators
|
||||
# Replace HasPrefix/TrimPrefix with CutPrefix.
|
||||
#
|
||||
# A useful hint because the code becomes shorter.
|
||||
|
||||
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package cache
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
@@ -195,9 +196,7 @@ func (c *volumeCache) dump(logger klog.Logger) {
|
||||
for volumeID := range c.volumes {
|
||||
volumeIDs = append(volumeIDs, volumeID)
|
||||
}
|
||||
sort.Slice(volumeIDs, func(i, j int) bool {
|
||||
return volumeIDs[i] < volumeIDs[j]
|
||||
})
|
||||
slices.Sort(volumeIDs)
|
||||
for _, volumeID := range volumeIDs {
|
||||
volume := c.volumes[volumeID]
|
||||
logger.Info("Cached volume", "volume", volumeID, "csiDriver", volume.csiDriver)
|
||||
|
||||
@@ -419,9 +419,7 @@ func createRequestsAndMappings(pod *v1.Pod, extendedResources map[v1.ResourceNam
|
||||
for resource := range extendedResources {
|
||||
resourceNames = append(resourceNames, resource)
|
||||
}
|
||||
sort.Slice(resourceNames, func(i, j int) bool {
|
||||
return resourceNames[i] < resourceNames[j]
|
||||
})
|
||||
slices.Sort(resourceNames)
|
||||
|
||||
for _, resource := range resourceNames {
|
||||
class := deviceClassMapping.GetDeviceClass(resource)
|
||||
|
||||
Reference in New Issue
Block a user