package common // Data. Predict: ["4"] // a := []string{"1","2","3","4"} // b := []string{"0","1","2","3"} func GetASliceInt32NotInB(a []int32, b []int32) []int32 { var c []int32 temp := map[int32]struct{}{} for _, val := range b { if _, ok := temp[val]; !ok { temp[val] = struct{}{} // 空struct 不占内存空间 } } for _, val := range a { if _, ok := temp[val]; !ok { c = append(c, val) } } return c }