Skip to content

Commit

Permalink
Merge pull request #55 from mrheinen/master
Browse files Browse the repository at this point in the history
Check if a field is private after confirming it has a ksql tag
  • Loading branch information
VinGarcia authored Nov 6, 2024
2 parents 0a95b40 + 688344f commit 24b9313
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,18 @@ 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")
if name == "" {
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 {
Expand Down

0 comments on commit 24b9313

Please sign in to comment.