diff --git a/helper/schema/field_writer_map.go b/helper/schema/field_writer_map.go index 3c9b0bf1ad5e..b9064709f603 100644 --- a/helper/schema/field_writer_map.go +++ b/helper/schema/field_writer_map.go @@ -237,13 +237,13 @@ func (w *MapFieldWriter) setPrimitive( if err := mapstructure.Decode(v, &n); err != nil { return fmt.Errorf("%s: %s", k, err) } + set = strconv.FormatInt(int64(n), 10) case TypeFloat: var n float64 if err := mapstructure.Decode(v, &n); err != nil { return fmt.Errorf("%s: %s", k, err) } - - set = strconv.FormatInt(int64(n), 10) + set = strconv.FormatFloat(float64(n), 'G', -1, 64) default: return fmt.Errorf("Unknown type: %#v", schema.Type) } diff --git a/helper/schema/resource_data_test.go b/helper/schema/resource_data_test.go index f628103478eb..f7b2118104ad 100644 --- a/helper/schema/resource_data_test.go +++ b/helper/schema/resource_data_test.go @@ -633,7 +633,7 @@ func TestResourceDataGet(t *testing.T) { Key: "ratio", - Value: []interface{}{0.0}, + Value: 0.0, }, // #21 Float given @@ -657,7 +657,7 @@ func TestResourceDataGet(t *testing.T) { Key: "ratio", - Value: []interface{}{0.5}, + Value: 0.5, }, // #22 Float diff @@ -689,7 +689,7 @@ func TestResourceDataGet(t *testing.T) { Key: "ratio", - Value: []interface{}{33.0}, + Value: 33.0, }, }