chore(validation): move functions from constants
- Move validation functions from `internal/constants` to `internal/configuration/settings/validation` - Concatenate all OpenVPN constants in `internal/constants/openvpn.go`
This commit is contained in:
23
internal/configuration/settings/validation/helpers.go
Normal file
23
internal/configuration/settings/validation/helpers.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package validation
|
||||
|
||||
import "sort"
|
||||
|
||||
func makeUnique(choices []string) (uniqueChoices []string) {
|
||||
seen := make(map[string]struct{}, len(choices))
|
||||
uniqueChoices = make([]string, 0, len(uniqueChoices))
|
||||
|
||||
for _, choice := range choices {
|
||||
if _, ok := seen[choice]; ok {
|
||||
continue
|
||||
}
|
||||
seen[choice] = struct{}{}
|
||||
|
||||
uniqueChoices = append(uniqueChoices, choice)
|
||||
}
|
||||
|
||||
sort.Slice(uniqueChoices, func(i, j int) bool {
|
||||
return uniqueChoices[i] < uniqueChoices[j]
|
||||
})
|
||||
|
||||
return uniqueChoices
|
||||
}
|
||||
Reference in New Issue
Block a user