1 // Copyright 2021 The Kubernetes Authors. 2 // SPDX-License-Identifier: Apache-2.0 3 4 package sliceutil 5 6 // Contains return true if string e is present in slice s 7 func Contains(s []string, e string) bool { 8 for _, a := range s { 9 if a == e { 10 return true 11 } 12 } 13 return false 14 } 15 16 // Remove removes the first occurrence of r in slice s 17 // and returns remaining slice 18 func Remove(s []string, r string) []string { 19 for i, v := range s { 20 if v == r { 21 return append(s[:i], s[i+1:]...) 22 } 23 } 24 return s 25 } 26