mirror of
https://github.com/Luzifer/vault-openvpn.git
synced 2024-11-15 03:22:46 +00:00
22 lines
429 B
Go
22 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
|
||
|
}
|