From 8ec89f1bbd969d10671c0b9e2263aa6da0726c79 Mon Sep 17 00:00:00 2001 From: Pete Davison Date: Sat, 17 Sep 2022 23:25:55 +0000 Subject: [PATCH] refactor: use x/exp/slices instead of custom contains function --- taskfile/included_taskfile.go | 3 ++- taskfile/slice.go | 10 ---------- taskfile/var.go | 3 ++- 3 files changed, 4 insertions(+), 12 deletions(-) delete mode 100644 taskfile/slice.go diff --git a/taskfile/included_taskfile.go b/taskfile/included_taskfile.go index f344eb54..3ee8822c 100644 --- a/taskfile/included_taskfile.go +++ b/taskfile/included_taskfile.go @@ -7,6 +7,7 @@ import ( "github.com/go-task/task/v3/internal/execext" "github.com/go-task/task/v3/internal/filepathext" + "golang.org/x/exp/slices" "gopkg.in/yaml.v3" ) @@ -72,7 +73,7 @@ func (tfs *IncludedTaskfiles) Set(key string, includedTaskfile IncludedTaskfile) if tfs.Mapping == nil { tfs.Mapping = make(map[string]IncludedTaskfile, 1) } - if !stringSliceContains(tfs.Keys, key) { + if !slices.Contains(tfs.Keys, key) { tfs.Keys = append(tfs.Keys, key) } tfs.Mapping[key] = includedTaskfile diff --git a/taskfile/slice.go b/taskfile/slice.go deleted file mode 100644 index 9cc50105..00000000 --- a/taskfile/slice.go +++ /dev/null @@ -1,10 +0,0 @@ -package taskfile - -func stringSliceContains(s []string, str string) bool { - for _, v := range s { - if v == str { - return true - } - } - return false -} diff --git a/taskfile/var.go b/taskfile/var.go index 65cc4fa4..0f807d8d 100644 --- a/taskfile/var.go +++ b/taskfile/var.go @@ -3,6 +3,7 @@ package taskfile import ( "errors" + "golang.org/x/exp/slices" "gopkg.in/yaml.v3" ) @@ -59,7 +60,7 @@ func (vs *Vars) Set(key string, value Var) { if vs.Mapping == nil { vs.Mapping = make(map[string]Var, 1) } - if !stringSliceContains(vs.Keys, key) { + if !slices.Contains(vs.Keys, key) { vs.Keys = append(vs.Keys, key) } vs.Mapping[key] = value