aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2016-07-08 07:52:02 -0700
committerJosh Bleecher Snyder <josharian@gmail.com>2016-08-21 22:47:03 +0000
commit65c5d62420a539f2f0d06b3ea2ba837f0fbdd6cf (patch)
tree3a2ecb782701ccf82229a5ccafea22a5a7b9309e /src/cmd
parent6ad76718cfdd59977b0008c1e774150a7e39fbd8 (diff)
downloadgo-65c5d62420a539f2f0d06b3ea2ba837f0fbdd6cf.tar.xz
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 <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/vet/structtag.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cmd/vet/structtag.go b/src/cmd/vet/structtag.go
index abff14fb1d..8134c585b3 100644
--- a/src/cmd/vet/structtag.go
+++ b/src/cmd/vet/structtag.go
@@ -34,7 +34,8 @@ func checkCanonicalFieldTag(f *File, node ast.Node) {
}
if err := validateStructTag(tag); err != nil {
- f.Badf(field.Pos(), "struct field tag %s not compatible with reflect.StructTag.Get: %s", field.Tag.Value, err)
+ raw, _ := strconv.Unquote(field.Tag.Value) // field.Tag.Value is known to be a quoted string
+ f.Badf(field.Pos(), "struct field tag %q not compatible with reflect.StructTag.Get: %s", raw, err)
}
// Check for use of json or xml tags with unexported fields.