package util // DedupeStrings returns a new slice holding each value of input once, in the // order in which each value first appears. The input slice is not modified. // A nil input returns nil. func DedupeStrings(input []string) []string { if input == nil { return nil } seen := make(map[string]struct{}, len(input)) out := make([]string, 0, len(input)) for _, value := range input { if _, ok := seen[value]; ok { continue } seen[value] = struct{}{} out = append(out, value) } return out }