forked from dasrick/go-teams-notify
-
Notifications
You must be signed in to change notification settings - Fork 17
/
textutils.go
29 lines (25 loc) · 627 Bytes
/
textutils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright 2022 Adam Chalkley
//
// https://github.com/atc0005/go-teams-notify
//
// Licensed under the MIT License. See LICENSE file in the project root for
// full license information.
package goteamsnotify
import (
"strings"
)
// InList is a helper function to emulate Python's `if "x" in list:`
// functionality. The caller can optionally ignore case of compared items.
func InList(needle string, haystack []string, ignoreCase bool) bool {
for _, item := range haystack {
if ignoreCase {
if strings.EqualFold(item, needle) {
return true
}
}
if item == needle {
return true
}
}
return false
}