forked from TrueCloudLab/certificates
Use map[string]struct{} instead of map[string]bool
This commit is contained in:
parent
c8eb771a8e
commit
9cc410b308
2 changed files with 3 additions and 3 deletions
|
@ -370,13 +370,13 @@ func DefaultIdentityFunc(ctx context.Context, p Interface, email string, usernam
|
||||||
// SanitizeStringSlices removes duplicated an empty strings.
|
// SanitizeStringSlices removes duplicated an empty strings.
|
||||||
func SanitizeStringSlices(original []string) []string {
|
func SanitizeStringSlices(original []string) []string {
|
||||||
output := []string{}
|
output := []string{}
|
||||||
seen := make(map[string]bool)
|
seen := make(map[string]struct{})
|
||||||
for _, entry := range original {
|
for _, entry := range original {
|
||||||
if entry == "" {
|
if entry == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if _, value := seen[entry]; !value {
|
if _, value := seen[entry]; !value {
|
||||||
seen[entry] = true
|
seen[entry] = struct{}{}
|
||||||
output = append(output, entry)
|
output = append(output, entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ func TestDefaultIdentityFunc(t *testing.T) {
|
||||||
return test{
|
return test{
|
||||||
p: &OIDC{},
|
p: &OIDC{},
|
||||||
email: "john@smallstep.com",
|
email: "john@smallstep.com",
|
||||||
usernames: []string{"johnny", "js", ""},
|
usernames: []string{"johnny", "js", "", "johnny", ""},
|
||||||
identity: &Identity{Usernames: []string{"johnny", "js", "john", "john@smallstep.com"}},
|
identity: &Identity{Usernames: []string{"johnny", "js", "john", "john@smallstep.com"}},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue