From ce42845acd4428a77abd6a5e1ec10c9f02324fbb Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 18 Aug 2014 14:24:04 -0700 Subject: [PATCH] helper/schema: use reflection to build []interface{} --- helper/schema/schema.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/helper/schema/schema.go b/helper/schema/schema.go index a36834481..9789c3a43 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -224,10 +224,15 @@ func (m schemaMap) diffList( } } - vs, ok := v.([]interface{}) - if !ok { + // We have to use reflection to build the []interface{} list + rawV := reflect.ValueOf(v) + if rawV.Kind() != reflect.Slice { return fmt.Errorf("%s: must be a list", k) } + vs := make([]interface{}, rawV.Len()) + for i, _ := range vs { + vs[i] = rawV.Index(i).Interface() + } // If this field is required, then it must also be non-empty if len(vs) == 0 && schema.Required {