Skip to content

Commit 65c5d62

Browse files
committed
cmd/vet: re-quote struct tags when printing errors
cmd/link/link_test.go contains several multi-line struct tags. Going through an unquote/quote cycle converts `a b c` to "a\nb\nc\n". This keeps all vet error messages for the standard library on a single line. Updates #11041 Change-Id: Ifba1e87297a5174294d1fbf73463fd3db357464f Reviewed-on: https://go-review.googlesource.com/27129 Run-TryBot: Josh Bleecher Snyder <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Rob Pike <[email protected]>
1 parent 6ad7671 commit 65c5d62

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/cmd/vet/structtag.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ func checkCanonicalFieldTag(f *File, node ast.Node) {
3434
}
3535

3636
if err := validateStructTag(tag); err != nil {
37-
f.Badf(field.Pos(), "struct field tag %s not compatible with reflect.StructTag.Get: %s", field.Tag.Value, err)
37+
raw, _ := strconv.Unquote(field.Tag.Value) // field.Tag.Value is known to be a quoted string
38+
f.Badf(field.Pos(), "struct field tag %q not compatible with reflect.StructTag.Get: %s", raw, err)
3839
}
3940

4041
// Check for use of json or xml tags with unexported fields.

0 commit comments

Comments
 (0)