Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cos.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,13 +627,13 @@ func decodeACL(resp *Response, res *ACLXml) {
}

func uniqueGrantID(grantIDs []string) string {
res := []string{}
filter := make(map[string]int)
res := make([]string, 0, len(grantIDs))
filter := make(map[string]struct{})
for _, id := range grantIDs {
if filter[id] != 0 {
if _, ok := filter[id]; ok {
continue
}
filter[id] = 1
filter[id] = struct{}{}
res = append(res, id)
}
return strings.Join(res, ",")
Expand Down
8 changes: 8 additions & 0 deletions cos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,11 @@ func Test_SwitchHost(t *testing.T) {
}

}

func TestUniqueGrantID(t *testing.T) {
ids := []string{"abc", "abc", "ab"}
actual := uniqueGrantID(ids)
if actual != "abc,ab" {
t.Errorf("expect uniqueIDs to be abc,ab, got %v", actual)
}
}