I have this function and i would like to make it be able to receive all types of slices, not only []string, but []int and so on... I would like to know if is there some way to abstract the type when passing the parameter to the function header or if i should do other thing to accomplish that.
package removeDuplicate
// RemoveDuplicate remove duplicate items from slice setting it to arr2
func RemoveDuplicate(arr []string) []string {
arr2 := arr[:1]
Loop:
for i := 1; i < len(arr); {
for j := 0; j < len(arr2); {
if arr[i] != arr[j] {
j++
} else {
i++
continue Loop
}
}
arr2 = append(arr2, arr[i])
i++
}
return arr2
}
Thanks in advance =]