From 7e1453e72fbf21b67179a6a175ded2cb61ce8fd4 Mon Sep 17 00:00:00 2001 From: some Date: Mon, 7 Oct 2024 18:34:43 -0400 Subject: [PATCH] Added fix for Header.Parse --- header.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/header.go b/header.go index 4ad100f..0bc5bc0 100644 --- a/header.go +++ b/header.go @@ -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 } }