MCPcopy Create free account
hub / github.com/compose-spec/compose-go / fixEmptyNotNull

Function fixEmptyNotNull

loader/fix.go:21–36  ·  view source on GitHub ↗

fixEmptyNotNull is a workaround for https://github.com/xeipuuv/gojsonschema/issues/141 as go-yaml `[]` will load as a `[]any(nil)`, which is not the same as an empty array

(value any)

Source from the content-addressed store, hash-verified

19// fixEmptyNotNull is a workaround for https://github.com/xeipuuv/gojsonschema/issues/141
20// as go-yaml `[]` will load as a `[]any(nil)`, which is not the same as an empty array
21func fixEmptyNotNull(value any) interface{} {
22 switch v := value.(type) {
23 case []any:
24 if v == nil {
25 return []any{}
26 }
27 for i, e := range v {
28 v[i] = fixEmptyNotNull(e)
29 }
30 case map[string]any:
31 for k, e := range v {
32 v[k] = fixEmptyNotNull(e)
33 }
34 }
35 return value
36}

Callers 1

loadYamlFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…