lbry.go/extras/util/slice.go

23 lines
429 B
Go
Raw Normal View History

2018-02-28 16:49:01 +01:00
package util
import "strings"
2018-02-28 16:49:01 +01:00
func InSlice(str string, values []string) bool {
for _, v := range values {
if str == v {
return true
}
}
return false
}
2018-07-24 02:01:35 +02:00
// SubstringInSlice returns true if str is contained within any element of the values slice. False otherwise
func SubstringInSlice(str string, values []string) bool {
for _, v := range values {
if strings.Contains(str, v) {
return true
}
}
return false
}