Users-Group Update API (#49)
* Added structure to swagger * Added updateUserGroups handlers * Updated return definition for user groups. * Logic rewrite * Removed logs * Added some tests to updateUserGroups * lint fix * Updated tests for the new API * Lint * Added comment about why we are setting this groups individually. & more lint fixes * Updated tests page * Added more tests & fixed comments for PR * Lint utils file * Fixed import orders * Changed import order Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
@@ -30,3 +30,27 @@ func DifferenceArrays(a, b []string) []string {
|
||||
}
|
||||
return diff
|
||||
}
|
||||
|
||||
// IsElementInSlice returns true if the string belongs to the slice
|
||||
func IsElementInArray(a []string, b string) bool {
|
||||
for _, e := range a {
|
||||
if e == b {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// UniqueKeys returns an array without duplicated keys
|
||||
func UniqueKeys(a []string) []string {
|
||||
keys := make(map[string]bool)
|
||||
list := []string{}
|
||||
for _, entry := range a {
|
||||
if _, value := keys[entry]; !value {
|
||||
keys[entry] = true
|
||||
list = append(list, entry)
|
||||
}
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user