Apply go fix -slicescontains ./...

This commit is contained in:
Michael Eischer
2026-07-22 22:26:33 +02:00
parent e2495b72bb
commit a2cb015591
5 changed files with 12 additions and 38 deletions
+3 -4
View File
@@ -10,6 +10,7 @@ import (
"path"
"path/filepath"
"runtime"
"slices"
"strconv"
"strings"
"time"
@@ -304,10 +305,8 @@ func (opts BackupOptions) Check(gopts global.Options, args []string) error {
}
filesFrom := append(append(opts.FilesFrom, opts.FilesFromVerbatim...), opts.FilesFromRaw...)
for _, filename := range filesFrom {
if filename == "-" {
return errors.Fatal("unable to read password from stdin when data is to be read from stdin, use --password-file or $RESTIC_PASSWORD")
}
if slices.Contains(filesFrom, "-") {
return errors.Fatal("unable to read password from stdin when data is to be read from stdin, use --password-file or $RESTIC_PASSWORD")
}
}
+2 -7
View File
@@ -8,6 +8,7 @@ import (
"os"
"path/filepath"
"runtime"
"slices"
"strings"
"testing"
"time"
@@ -630,13 +631,7 @@ func linkEqual(source, dest []string) bool {
}
for i := range source {
found := false
for j := range dest {
if source[i] == dest[j] {
found = true
break
}
}
found := slices.Contains(dest, source[i])
if !found {
return false
}
+2 -7
View File
@@ -3,6 +3,7 @@ package main
import (
"context"
"encoding/json"
"slices"
"strings"
"github.com/spf13/cobra"
@@ -49,13 +50,7 @@ func validateCatArgs(args []string) error {
return errors.Fatal("type not specified")
}
validType := false
for _, v := range catAllowedCmds {
if v == args[0] {
validType = true
break
}
}
validType := slices.Contains(catAllowedCmds, args[0])
if !validType {
return errors.Fatalf("invalid type %q, must be one of [%s]", args[0], strings.Join(catAllowedCmds, "|"))
}
+2 -7
View File
@@ -9,6 +9,7 @@ import (
"os"
"path/filepath"
"runtime"
"slices"
"strings"
"testing"
@@ -339,13 +340,7 @@ func removePacksExcept(gopts global.Options, t testing.TB, keep restic.IDSet, re
}
func includes(haystack []string, needle string) bool {
for _, s := range haystack {
if s == needle {
return true
}
}
return false
return slices.Contains(haystack, needle)
}
func loadSnapshotMap(t testing.TB, gopts global.Options) map[string]struct{} {