flatmap: never auto-convert ints

This commit is contained in:
Mitchell Hashimoto 2014-07-24 11:40:46 -07:00
parent e2aeacc8d2
commit 308b88a8d8
2 changed files with 4 additions and 6 deletions

View File

@ -11,9 +11,7 @@ import (
func Expand(m map[string]string, key string) interface{} {
// If the key is exactly a key in the map, just return it
if v, ok := m[key]; ok {
if num, err := strconv.ParseInt(v, 0, 0); err == nil {
return int(num)
} else if v == "true" {
if v == "true" {
return true
} else if v == "false" {
return false

View File

@ -44,7 +44,7 @@ func TestExpand(t *testing.T) {
Output: []interface{}{
map[string]interface{}{
"name": "bar",
"port": 3000,
"port": "3000",
"enabled": true,
},
},
@ -63,8 +63,8 @@ func TestExpand(t *testing.T) {
map[string]interface{}{
"name": "bar",
"ports": []interface{}{
1,
2,
"1",
"2",
},
},
},