mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
pkg/flags: fix UniqueURLs'Set to remove duplicates in UniqueURLs'uss
From the name of func 'UniqueURLsFromFlag', we can tell that UniqueURLs'uss should not have duplicates. The current implemention of UniqueURLs'Set has a bug to make it unique. Fixes: #16307. Signed-off-by: Jes Cok <xigua67damn@gmail.com>
This commit is contained in:
@@ -50,7 +50,11 @@ func (us *UniqueURLs) Set(s string) error {
|
||||
us.Values = make(map[string]struct{})
|
||||
us.uss = make([]url.URL, 0)
|
||||
for _, v := range ss {
|
||||
us.Values[v.String()] = struct{}{}
|
||||
x := v.String()
|
||||
if _, exists := us.Values[x]; exists {
|
||||
continue
|
||||
}
|
||||
us.Values[x] = struct{}{}
|
||||
us.uss = append(us.uss, v)
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user