import "fmt"
func removeDuplicateElement(addrs []string) []string {
result := make([]string, 0, len(addrs))
temp := map[string]struct{}{}
idx := 0
for _, item := range addrs {
if _, ok := temp[item]; !ok {
temp[item] = struct{}{}
result = append(result, item)
} else {
idx++
item += fmt.Sprintf("(%v)", idx)
result = append(result, item)
}
}
return result
}
func main() {
fmt.Println(removeDuplicateElement([]string{"fsdf","fdsfsdf","fsdf"}))
}
[fsdf fdsfsdf fsdf(1)]