D functions/functions.go => functions/functions.go +0 -12
@@ 1,12 0,0 @@
-package functions
-
-// SliceContains checks if slice s contains element e and returns index
-func SliceContains(s []string, e string) (bool, int) {
- for i, v := range s {
- if e == v {
- return true, i
- }
- }
-
- return false, 0
-}
M graph/schema.resolvers.go => graph/schema.resolvers.go +3 -3
@@ 14,10 14,10 @@ import (
"log/slog"
"math/rand"
"net/http"
+ "slices"
"time"
"git.xenrox.net/~xenrox/10man-api/database"
- "git.xenrox.net/~xenrox/10man-api/functions"
"git.xenrox.net/~xenrox/10man-api/graph/generated"
"git.xenrox.net/~xenrox/10man-api/graph/model"
"git.xenrox.net/~xenrox/10man-api/logic"
@@ 460,8 460,8 @@ func (r *mutationResolver) VetoMap(ctx context.Context, mapArg *string) (*model.
length := len(voteMaps)
// check if voted map is in remaining
- contains, i := functions.SliceContains(voteMaps, *mapArg)
- if !contains {
+ i := slices.Index(voteMaps, *mapArg)
+ if i == -1 {
return nil, errors.New("no legal vote")
}
voteMaps[i] = voteMaps[length-1]