util: use slices package for contains

use slices package to check whether
the slice contains the element or not.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna
2024-04-02 10:11:04 +02:00
committed by mergify[bot]
parent 86b5db90bc
commit 1e0254daba
3 changed files with 6 additions and 35 deletions

View File

@ -23,6 +23,7 @@ import (
"math"
"os"
"runtime"
"slices"
"strings"
"time"
@ -363,7 +364,7 @@ func MountOptionsAdd(options string, add ...string) string {
}
for _, opt := range add {
if opt != "" && !contains(newOpts, opt) {
if opt != "" && !slices.Contains(newOpts, opt) {
newOpts = append(newOpts, opt)
}
}
@ -371,16 +372,6 @@ func MountOptionsAdd(options string, add ...string) string {
return strings.Join(newOpts, ",")
}
func contains(s []string, key string) bool {
for _, v := range s {
if v == key {
return true
}
}
return false
}
// CallStack returns the stack of the calls in the current goroutine. Useful
// for debugging or reporting errors. This is a friendly alternative to
// assert() or panic().