From 688344f71007ce71d03e6adb3067a433dfeaee38 Mon Sep 17 00:00:00 2001 From: niels Date: Wed, 6 Nov 2024 20:35:26 +0100 Subject: [PATCH] Check if a field is private after confirming it has a ksql tag --- internal/structs/structs.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/structs/structs.go b/internal/structs/structs.go index 5e74f49..3da750d 100644 --- a/internal/structs/structs.go +++ b/internal/structs/structs.go @@ -257,10 +257,6 @@ func getTagNames(t reflect.Type) (_ StructInfo, err error) { byName: map[string]*FieldInfo{}, } for i := 0; i < t.NumField(); i++ { - // If this field is private: - if t.Field(i).PkgPath != "" { - return StructInfo{}, fmt.Errorf("all fields using the ksql tags must be exported, but %v is unexported", t) - } attrName := t.Field(i).Name name := t.Field(i).Tag.Get("ksql") @@ -268,6 +264,11 @@ func getTagNames(t reflect.Type) (_ StructInfo, err error) { continue } + // If this field is private: + if t.Field(i).PkgPath != "" { + return StructInfo{}, fmt.Errorf("all fields using the ksql tags must be exported, but %v is unexported", t) + } + tags := strings.Split(name, ",") var modifier ksqlmodifiers.AttrModifier if len(tags) > 1 {