github.com/coveo/gotemplate@v2.7.7+incompatible/utils/reflect.go (about) 1 package utils 2 3 import ( 4 "github.com/coveo/gotemplate/collections" 5 ) 6 7 // String is simply an alias of collections.String 8 type String = collections.String 9 10 var isEmpty = collections.IsEmptyValue 11 12 // MergeDictionaries merges multiple dictionaries into a single one prioritizing the first ones. 13 func MergeDictionaries(args ...map[string]interface{}) (map[string]interface{}, error) { 14 if len(args) == 0 { 15 return make(map[string]interface{}), nil 16 } 17 dicts := make([]collections.IDictionary, len(args)) 18 for i := range dicts { 19 var err error 20 dicts[i], err = collections.TryAsDictionary(args[i]) 21 if err != nil { 22 return nil, err 23 } 24 } 25 26 result := collections.CreateDictionary() 27 return result.Merge(dicts[0], dicts[1:]...).Native().(map[string]interface{}), nil 28 }