MCPcopy Create free account
hub / github.com/cloudwan/gohan / DecodeYAMLLibObject

Function DecodeYAMLLibObject

util/util.go:155–173  ·  view source on GitHub ↗

DecodeYAMLLibObject decodes interface format yaml.v2 lib returns map as map[interface{}]interface{} while gohan lib uses map[string]interface{} so we need to convert it here

(yamlData interface{})

Source from the content-addressed store, hash-verified

153//yaml.v2 lib returns map as map[interface{}]interface{} while gohan lib uses map[string]interface{}
154//so we need to convert it here
155func DecodeYAMLLibObject(yamlData interface{}) interface{} {
156 yamlMap, ok := yamlData.(map[interface{}]interface{})
157 if ok {
158 mapData := map[string]interface{}{}
159 for key, value := range yamlMap {
160 mapData[key.(string)] = DecodeYAMLLibObject(value)
161 }
162 return mapData
163 }
164 yamlList, ok := yamlData.([]interface{})
165 if ok {
166 mapList := []interface{}{}
167 for _, value := range yamlList {
168 mapList = append(mapList, DecodeYAMLLibObject(value))
169 }
170 return mapList
171 }
172 return yamlData
173}
174
175//GetContent loads file from remote or local
176func GetContent(url string) ([]byte, error) {

Callers 2

LoadFileFunction · 0.85
LoadTemplateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected