func GetSliceFeatures(v *viper.Viper, features map[string]bool, key string) []interface{} { val := v.Get(key) vals := []interface{}{val} // Process the features in alphabetical order to ensure consistent // results across repeated runs. var featureKeys []string for feature, _ := range features { featureKeys = append(featureKeys, feature) } sort.Strings(featureKeys) for _, feature := range featureKeys { overwriteVal := v.Get(key + "." + feature + ".OVERWRITE") if overwriteVal != nil { return []interface{}{overwriteVal} } appendVal := v.Get(key + "." + feature) if appendVal != nil { vals = append(vals, appendVal) } } return vals }