From: Sergey Matveev Date: Thu, 10 Apr 2025 07:15:15 +0000 (+0300) Subject: Make slice only after the check is done X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1468ca7608bd6c30d9dbffbd4d283225ca31231113955ceb34200ffadbe4213d;p=keks.git Make slice only after the check is done --- diff --git a/go/schema/check.go b/go/schema/check.go index 9b26691..83b79ef 100644 --- a/go/schema/check.go +++ b/go/schema/check.go @@ -273,7 +273,6 @@ func Check(schemaName string, schemas map[string][][]any, data any) error { if vs == nil { continue } - expected := make([]types.Type, 0, len(cmd)-1) if len(cmd) < 2 { return &SchemaErr{BaseErr: BaseErr{ SchemaName: schemaName, @@ -282,6 +281,7 @@ func Check(schemaName string, schemas map[string][][]any, data any) error { Msg: "wrong number of args", }} } + expected := make([]types.Type, 0, len(cmd)-1) for _, tAny := range cmd[1:] { var t string t, ok = tAny.(string)