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"))
|
panic(fmt.Errorf("expected struct input for data"))
|
||||||
}
|
}
|
||||||
for i := 0; i < d.NumField(); i++ {
|
for i := 0; i < d.NumField(); i++ {
|
||||||
key := d.Type().Field(i).Tag.Get("header")
|
key, ok := d.Type().Field(i).Tag.Lookup("header")
|
||||||
if key == "" {
|
if !ok || key == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
v := make([]string, 0)
|
v := make([]string, 0)
|
||||||
@ -32,11 +32,12 @@ func (h Header) Parse(data any) {
|
|||||||
if item.Kind() == reflect.Pointer || item.Kind() == reflect.Interface {
|
if item.Kind() == reflect.Pointer || item.Kind() == reflect.Interface {
|
||||||
item = item.Elem()
|
item = item.Elem()
|
||||||
}
|
}
|
||||||
v = append(v, fmt.Sprint(item.Interface()))
|
v = append(v, fmt.Sprintf("%s", item.Interface()))
|
||||||
}
|
}
|
||||||
} else {
|
} 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