modernize: Use strings.CutSuffix

Added in Go 1.20

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski
2025-12-15 18:32:55 +01:00
parent 71fd582aa2
commit 6c5233e109
6 changed files with 15 additions and 15 deletions

View File

@@ -76,8 +76,8 @@ func GenerateKey(containerID string) string {
for _, v := range dir {
id := v.Name()
if strings.HasSuffix(id, containerID[:maxLen-1]) {
indexStr = strings.TrimSuffix(id, containerID[:maxLen-1])
if before, ok := strings.CutSuffix(id, containerID[:maxLen-1]); ok {
indexStr = before
tmpindex, err := strconv.Atoi(indexStr)
if err != nil {
return ""