数组去重
import (
mapset "github.com/deckarep/golang-set"
)
//合并两个字符串数组并去重
func MergeDuplicateStringArray(slice []string, elems []string) []string {
listPId := append(slice, elems...)
t := mapset.NewSet()
for _, i := range listPId {
t.Add(i)
}
var result []string
for i := range t.Iterator().C {
result = append(result, i.(string))
}
return result
}
网友评论