liujiandao
2023-11-14 d6f4e3fe92d1da0c028ac61289a759cc4b8c993e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
package slicex
 
// RemoveRepeatString 元素去重
func RemoveRepeatString(slc []string) []string {
    result := make([]string, 0)
    tempMap := make(map[string]bool, len(slc))
    for _, e := range slc {
        if tempMap[e] == false {
            tempMap[e] = true
            result = append(result, e)
        }
    }
    return result
}