Sort map keys for consistency

Signed-off-by: jolheiser <john.olheiser@gmail.com>
pull/7/head
jolheiser 2020-11-16 23:47:11 -06:00
parent c5bf199b84
commit e4342f9a04
Signed by: jolheiser
GPG Key ID: B853ADA5DA7BBF7A
1 changed files with 9 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"sort"
"strings"
"time"
@ -105,9 +106,16 @@ func prompt(dir string) (map[string]interface{}, error) {
return nil, err
}
// Sort the map keys so they are consistent
vars := tree.ToMap()
sorted := make([]string, 0, len(vars))
for k := range vars {
sorted = append(sorted, k)
}
sort.Strings(sorted)
for k, v := range vars {
for _, k := range sorted {
v := vars[k]
var p survey.Prompt
switch t := v.(type) {
case []string: