💄 Give better names to the files in utils package

This commit is contained in:
M. Mert Yildiran
2022-11-26 21:34:45 +03:00
parent 127bea3449
commit fa5a87b9d5
6 changed files with 0 additions and 0 deletions

39
utils/slice.go Normal file
View File

@@ -0,0 +1,39 @@
package utils
func Contains(slice []string, containsValue string) bool {
for _, sliceValue := range slice {
if sliceValue == containsValue {
return true
}
}
return false
}
func Unique(slice []string) []string {
keys := make(map[string]bool)
var list []string
for _, entry := range slice {
if _, value := keys[entry]; !value {
keys[entry] = true
list = append(list, entry)
}
}
return list
}
func EqualStringSlices(slice1 []string, slice2 []string) bool {
if len(slice1) != len(slice2) {
return false
}
for _, v := range slice1 {
if !Contains(slice2, v) {
return false
}
}
return true
}