From 6bedcd10978a1d1183f0f20ed24adb2451e3bf89 Mon Sep 17 00:00:00 2001 From: Marcel van Lohuizen Date: Tue, 12 Feb 2019 23:22:36 +0400 Subject: [PATCH] go/analysis/passes/printf: add support for %w Change-Id: I91bd2a1f3f65f95258fa5a5b91aca51ff0885bad Reviewed-on: https://go-review.googlesource.com/c/162058 Run-TryBot: Marcel van Lohuizen Reviewed-by: Damien Neil --- go/analysis/passes/printf/printf.go | 1 + go/analysis/passes/printf/testdata/src/a/a.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/go/analysis/passes/printf/printf.go b/go/analysis/passes/printf/printf.go index c0265aafeee..8f657b1bfa6 100644 --- a/go/analysis/passes/printf/printf.go +++ b/go/analysis/passes/printf/printf.go @@ -731,6 +731,7 @@ var printVerbs = []printVerb{ {'T', "-", anyType}, {'U', "-#", argRune | argInt}, {'v', allFlags, anyType}, + {'w', noFlag, anyType}, {'x', sharpNumFlag, argRune | argInt | argString | argPointer}, {'X', sharpNumFlag, argRune | argInt | argString | argPointer}, } diff --git a/go/analysis/passes/printf/testdata/src/a/a.go b/go/analysis/passes/printf/testdata/src/a/a.go index 417ca91efe5..4aeecd561e4 100644 --- a/go/analysis/passes/printf/testdata/src/a/a.go +++ b/go/analysis/passes/printf/testdata/src/a/a.go @@ -63,6 +63,7 @@ func PrintfTests() { var imap map[int]int var fslice []float64 var c complex64 + var err error // Some good format/argtypes fmt.Printf("") fmt.Printf("%b %b %b", 3, i, x) @@ -96,6 +97,7 @@ func PrintfTests() { fmt.Printf("%T", notstringerv) fmt.Printf("%q", stringerarrayv) fmt.Printf("%v", stringerarrayv) + fmt.Printf("%w", err) fmt.Printf("%s", stringerarrayv) fmt.Printf("%v", notstringerarrayv) fmt.Printf("%T", notstringerarrayv)