There is two slices in string type.I want to finding intercept result in set from the two slices in golang.I want to find the best solution rather than iterating each slice.
first_slice := []string{"F8-E7-1E-14-AE-00", "F8-E7-1E-14-D0-30", "84-18-3A-2F-05-E0","84-18-3A-2F-05-E8" }
second_slice := []string{"F8-E7-1E-14-D0-30", "84-18-3A-2F-05-E8","F8-E7-1E-54-AE-08"}
Output:
result_slice := []string{"F8-E7-1E-14-D0-30", "84-18-3A-2F-05-E8"}
I have use following approaches but it is not best approaches for large data set.
var result_slice *[]string
for _, i := range first_slice {
for _, x := range second_slice {
if i == x {
&result_slice.append(i)
}
}
}
Appreciate if give me good solution that.