aranGO
aranGO copied to clipboard
Tags : infinite loop
Let me know if i'm wrong :
func getTags(obj reflect.Type, tags map[string]string, key string) {
if obj.Kind() != reflect.Struct && obj.Kind() != reflect.Ptr {
return
}
var tag string
fieldsCount := obj.NumField()
for i := 0; i < fieldsCount; i++ {
structField := obj.Field(i)
if structField.Anonymous && structField.Type.Kind() == reflect.Struct {
getTags(obj, tags, key)
} else {
tag = structField.Tag.Get(key)
if tag != "" {
tags[structField.Name] = tag
}
}
}
}
So if it's another struct, it will call itself with the same tag (obj)
Result in a infinite loop (overflow)
Possible solution: replaced with structField.Type
getTags(structField.Type, tags, key)
=== Step to reproduce ===
In a model
type Model struct {
aranGO.Document
}
type Event struct {
Model
Title string `json:"title"`
}
The embedded struct should cause the SO
hi @malletjo , thanks for the report. I will check this now