Skip to content

Commit 993a2bd

Browse files
committed
workaround for ΛEnumTypes declaration limit
As described in golang/go#33437 (comment) maps of too large size cannot be defined declaratively. So I split the map in a Key (ΛEnumTypesKeys) and a Value (ΛEnumTypesValues) Slice and compose the ΛEnumTypes map via init().
1 parent 6cdb0cb commit 993a2bd

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

ygen/gogen.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,9 @@ var (
418418
419419
func init() {
420420
var err error
421+
for i:=0; i < len(ΛEnumTypesKeys); i++{
422+
ΛEnumTypes[ΛEnumTypesKeys[i]] = ΛEnumTypesValues[i]
423+
}
421424
if SchemaTree, err = UnzipSchema(); err != nil {
422425
panic("schema error: " + err.Error())
423426
}
@@ -1017,9 +1020,17 @@ var ΛEnum = map[string]map[int64]ygot.EnumDefinition{
10171020
// ΛEnumTypes is a map, keyed by a YANG schema path, of the enumerated types that
10181021
// correspond with the leaf. The type is represented as a reflect.Type. The naming
10191022
// of the map ensures that there are no clashes with valid YANG identifiers.
1020-
var ΛEnumTypes = map[string][]reflect.Type{
1021-
{{- range $schemapath, $types := . }}
1022-
"{{ $schemapath }}": []reflect.Type{
1023+
var ΛEnumTypes = map[string][]reflect.Type{}
1024+
1025+
var ΛEnumTypesKeys = []string{
1026+
{{- range $schemapath, $types := . }}
1027+
"{{ $schemapath }}",
1028+
{{- end }}
1029+
}
1030+
1031+
var ΛEnumTypesValues = [][]reflect.Type{
1032+
{{- range $schemapath, $types := . }}
1033+
[]reflect.Type{
10231034
{{- range $i, $t := $types }}
10241035
reflect.TypeOf(({{ $t }})(0)),
10251036
{{- end }}

0 commit comments

Comments
 (0)