]> Cypherpunks repositories - gostls13.git/commit
cmd/vet: fix some pointer false positives in printf
authorDaniel Martí <mvdan@mvdan.cc>
Tue, 6 Nov 2018 15:14:56 +0000 (15:14 +0000)
committerDaniel Martí <mvdan@mvdan.cc>
Fri, 9 Nov 2018 14:57:28 +0000 (14:57 +0000)
commitedb2d1cbf23c1a638837f21bc7dd51a0807ab236
tree5d3022b28de89b3d5366ea8e67b96935b16a5668
parentef2c48659880c7e8a989e6721a21f018790f7793
cmd/vet: fix some pointer false positives in printf

fmt's godoc reads:

For compound objects, the elements are printed using these
rules, recursively, laid out like this:

struct:             {field0 field1 ...}
array, slice:       [elem0 elem1 ...]
maps:               map[key1:value1 key2:value2 ...]
pointer to above:   &{}, &[], &map[]

That is, a pointer to a struct, array, slice, or map, can be correctly
printed by fmt if the type pointed to can be printed without issues.

vet was only following this rule for pointers to structs, omitting
arrays, slices, and maps. Fix that, and add tests for all the
combinations.

Updates #27672.

Change-Id: Ie61ebe1fffc594184f7b24d7dbf72d7d5de78309
Reviewed-on: https://go-review.googlesource.com/c/147758
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
src/cmd/vet/testdata/print.go
src/cmd/vet/types.go