From 3e14fe48d3c33f3f985e9a6d224772c6b1338b65 Mon Sep 17 00:00:00 2001 From: Ricardo Galli Date: Mon, 25 Oct 2021 14:54:49 +0200 Subject: [PATCH] Ignore if stringer IsZero() and w.ignorezerovalue --- hashstructure.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hashstructure.go b/hashstructure.go index 3dc0eb7..9bcafcf 100644 --- a/hashstructure.go +++ b/hashstructure.go @@ -332,6 +332,9 @@ func (w *walker) visit(v reflect.Value, opts *visitOpts) (uint64, error) { if tag == "string" || w.stringer { if impl, ok := innerV.Interface().(fmt.Stringer); ok { innerV = reflect.ValueOf(impl.String()) + if w.ignorezerovalue && innerV.IsZero() { + continue + } } else if tag == "string" { // We only show this error if the tag explicitly // requests a stringer.