github.com/golangci/go-tools@v0.0.0-20190318060251-af6baa5dc196/simple/testdata/src/LintRedundantSprintf/LintRedundantSprintf.go (about) 1 package pkg 2 3 import "fmt" 4 5 type T1 string 6 type T2 T1 7 type T3 int 8 type T4 int 9 type T5 int 10 type T6 string 11 12 func (T3) String() string { return "" } 13 func (T6) String() string { return "" } 14 func (T4) String(arg int) string { return "" } 15 func (T5) String() {} 16 17 func fn() { 18 var t1 T1 19 var t2 T2 20 var t3 T3 21 var t4 T4 22 var t5 T5 23 var t6 T6 24 _ = fmt.Sprintf("%s", "test") // MATCH "is already a string" 25 _ = fmt.Sprintf("%s", t1) // MATCH "is a string" 26 _ = fmt.Sprintf("%s", t2) // MATCH "is a string" 27 _ = fmt.Sprintf("%s", t3) // MATCH "should use String() instead of fmt.Sprintf" 28 _ = fmt.Sprintf("%s", t3.String()) // MATCH "is already a string" 29 _ = fmt.Sprintf("%s", t4) 30 _ = fmt.Sprintf("%s", t5) 31 _ = fmt.Sprintf("%s %s", t1, t2) 32 _ = fmt.Sprintf("%v", t1) 33 _ = fmt.Sprintf("%s", t6) // MATCH "should use String() instead of fmt.Sprintf" 34 }