package main
import (
"fmt"
)
func UnionTwoSlice(slice1, slice2 []int) []int {
m := make(map[int]bool)
for _, item := range slice1 {
m[item] = true
}
for _, item := range slice2 {
if _, ok := m[item]; !ok {
slice1 = append(slice1, item)
}
}
return slice1
}
func main() {
var slice1 = []int{8, 6, 11, 21, 156}
var slice2 = []int{9, 11, 8, 111, 21, 6, 100}
fmt.Println(UnionTwoSlice(slice1, slice2))
}
Output
[8 6 11 21 156 9 111 100]