aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2019-04-30 13:32:57 -0400
committerRuss Cox <rsc@golang.org>2019-05-01 15:18:09 +0000
commitdc6db5f4340675a6c05d03382728d739208d7a3c (patch)
treea5a70dda8f169e4781985d24a72a1f49f8bd6d94
parent9ac70939841cbc07ac3e90cb7343a4726ead1010 (diff)
downloadgo-dc6db5f4340675a6c05d03382728d739208d7a3c.tar.gz
go-dc6db5f4340675a6c05d03382728d739208d7a3c.zip
[release-branch.go1.12] cmd/vet: add tests for point-release issues
Add explicit tests for: #30465 cmd/vet: Consider reverting tag conflict for embedded fields #30399 cmd/vet: possible to get a printf false positive with big.Int because we have managed not to fix them in the last couple point releases, and it will be too embarrassing to do that yet again. Change-Id: Ib1da5df870348b6eb9bfc8a87c507ecc6d44b8dd Reviewed-on: https://go-review.googlesource.com/c/go/+/174520 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-rw-r--r--src/cmd/vet/testdata/src/print2/big.go17
-rw-r--r--src/cmd/vet/testdata/src/structtag/structtag.go14
-rw-r--r--src/cmd/vet/vet_test.go1
3 files changed, 32 insertions, 0 deletions
diff --git a/src/cmd/vet/testdata/src/print2/big.go b/src/cmd/vet/testdata/src/print2/big.go
new file mode 100644
index 0000000000..dd5bef55f6
--- /dev/null
+++ b/src/cmd/vet/testdata/src/print2/big.go
@@ -0,0 +1,17 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package print2
+
+import ( // NOTE: Does not import "fmt"
+ "log"
+ "math/big"
+)
+
+var fmt int
+
+func f() {
+ log.Printf("%d", new(big.Int))
+ log.Printf("%d", 1.0) // ERROR "Printf format %d has arg 1.0 of wrong type float64"
+}
diff --git a/src/cmd/vet/testdata/src/structtag/structtag.go b/src/cmd/vet/testdata/src/structtag/structtag.go
index cbcc453376..e40139e8b1 100644
--- a/src/cmd/vet/testdata/src/structtag/structtag.go
+++ b/src/cmd/vet/testdata/src/structtag/structtag.go
@@ -6,6 +6,20 @@
package structtag
+import "encoding/json"
+
type StructTagTest struct {
A int "hello" // ERROR "`hello` not compatible with reflect.StructTag.Get: bad syntax for struct tag pair"
}
+
+func Issue30465() {
+ type T1 struct {
+ X string `json:"x"`
+ }
+ type T2 struct {
+ T1
+ X string `json:"x"`
+ }
+ var t2 T2
+ json.Marshal(&t2)
+}
diff --git a/src/cmd/vet/vet_test.go b/src/cmd/vet/vet_test.go
index d106c5c29c..f3b9a56515 100644
--- a/src/cmd/vet/vet_test.go
+++ b/src/cmd/vet/vet_test.go
@@ -88,6 +88,7 @@ func TestVet(t *testing.T) {
"method",
"nilfunc",
"print",
+ "print2",
"rangeloop",
"shift",
"structtag",