github.com/Tyktechnologies/tyk@v2.9.5+incompatible/gateway/util.go (about) 1 package gateway 2 3 // appendIfMissing appends the given new item to the given slice. 4 func appendIfMissing(slice []string, newSlice ...string) []string { 5 for _, new := range newSlice { 6 found := false 7 for _, item := range slice { 8 if item == new { 9 continue 10 } 11 found = true 12 } 13 14 if !found { 15 slice = append(slice, new) 16 } 17 } 18 19 return slice 20 } 21 22 // contains checks whether the given slice contains the given item. 23 func contains(s []string, i string) bool { 24 for _, a := range s { 25 if a == i { 26 return true 27 } 28 } 29 return false 30 }