mirror of https://github.com/hashicorp/consul
create lib/stringslice package (#7934)
parent
12f6d327f8
commit
77f2e54618
@ -1,11 +0,0 @@
|
||||
package lib
|
||||
|
||||
// StrContains checks if a list contains a string
|
||||
func StrContains(l []string, s string) bool {
|
||||
for _, v := range l {
|
||||
if v == s {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package lib
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestStrContains(t *testing.T) {
|
||||
l := []string{"a", "b", "c"}
|
||||
if !StrContains(l, "b") {
|
||||
t.Fatalf("should contain")
|
||||
}
|
||||
if StrContains(l, "d") {
|
||||
t.Fatalf("should not contain")
|
||||
}
|
||||
}
|
Loading…
Reference in new issue