From dc5bde97d79b0c61d002ca7de1f7377e457ed6fe Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Tue, 7 Jan 2020 12:11:50 +0100 Subject: [PATCH] log& skip field if struct tag parse did not work --- cmd/mapstructure-to-hcl2/mapstructure-to-hcl2.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/mapstructure-to-hcl2/mapstructure-to-hcl2.go b/cmd/mapstructure-to-hcl2/mapstructure-to-hcl2.go index 90d9d7362..3880c35aa 100644 --- a/cmd/mapstructure-to-hcl2/mapstructure-to-hcl2.go +++ b/cmd/mapstructure-to-hcl2/mapstructure-to-hcl2.go @@ -415,7 +415,11 @@ func getMapstructureSquashedStruct(topPkg *types.Package, utStruct *types.Struct if _, ok := field.Type().(*types.Signature); ok { continue // ignore funcs } - structtag, _ := structtag.Parse(tag) + structtag, err := structtag.Parse(tag) + if err != nil { + log.Printf("could not parse field tag %s of : %v", tag, err) + continue + } if ms, err := structtag.Get("mapstructure"); err != nil { //no mapstructure tag } else if ms.HasOption("squash") {