1
0
Fork 0
mirror of https://github.com/Luzifer/expose.git synced 2024-11-13 00:22:50 +00:00
expose/vendor/github.com/Luzifer/go_helpers/str/slice.go
Knut Ahlers 360c8ec055
Switch to dep for vendoring
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2018-09-17 21:32:52 +02:00

21 lines
429 B
Go

package str
// AppendIfMissing adds a string to a slice when it's not present yet
func AppendIfMissing(slice []string, s string) []string {
for _, e := range slice {
if e == s {
return slice
}
}
return append(slice, s)
}
// StringInSlice checks for the existence of a string in the slice
func StringInSlice(a string, list []string) bool {
for _, b := range list {
if b == a {
return true
}
}
return false
}