Added fix for Header.Parse
This commit is contained in:
parent
8436196447
commit
7e1453e72f
@ -17,8 +17,8 @@ func (h Header) Parse(data any) {
|
||||
panic(fmt.Errorf("expected struct input for data"))
|
||||
}
|
||||
for i := 0; i < d.NumField(); i++ {
|
||||
key := d.Type().Field(i).Tag.Get("header")
|
||||
if key == "" {
|
||||
key, ok := d.Type().Field(i).Tag.Lookup("header")
|
||||
if !ok || key == "" {
|
||||
continue
|
||||
}
|
||||
v := make([]string, 0)
|
||||
@ -32,11 +32,12 @@ func (h Header) Parse(data any) {
|
||||
if item.Kind() == reflect.Pointer || item.Kind() == reflect.Interface {
|
||||
item = item.Elem()
|
||||
}
|
||||
v = append(v, fmt.Sprint(item.Interface()))
|
||||
v = append(v, fmt.Sprintf("%s", item.Interface()))
|
||||
}
|
||||
} else {
|
||||
v = append(v, fmt.Sprint(val.Interface()))
|
||||
v = append(v, fmt.Sprintf("%s", val.Interface()))
|
||||
}
|
||||
h[key] = v
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user