|
|
|
@@ -87,6 +87,24 @@ func StringsContains(strs []string, str string) bool { |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
// StringsSubtract returns elements from source that are not in exclude. |
|
|
|
func StringsSubtract(source, exclude []string) []string { |
|
|
|
if len(exclude) == 0 { |
|
|
|
return source |
|
|
|
} |
|
|
|
excludeSet := make(map[string]struct{}, len(exclude)) |
|
|
|
for _, s := range exclude { |
|
|
|
excludeSet[s] = struct{}{} |
|
|
|
} |
|
|
|
result := make([]string, 0, len(source)) |
|
|
|
for _, s := range source { |
|
|
|
if _, ok := excludeSet[s]; !ok { |
|
|
|
result = append(result, s) |
|
|
|
} |
|
|
|
} |
|
|
|
return result |
|
|
|
} |
|
|
|
|
|
|
|
// StringToByteSlice []byte only read, panic on append |
|
|
|
func StringToByteSlice(s string) []byte { |
|
|
|
tmp1 := (*[2]uintptr)(unsafe.Pointer(&s)) |
|
|
|
|