diff --git a/go/analysis/passes/stringintconv/string.go b/go/analysis/passes/stringintconv/string.go index ac2cd84ad3..7a005901e8 100644 --- a/go/analysis/passes/stringintconv/string.go +++ b/go/analysis/passes/stringintconv/string.go @@ -101,7 +101,7 @@ func run(pass *analysis.Pass) (interface{}, error) { } diag := analysis.Diagnostic{ Pos: n.Pos(), - Message: fmt.Sprintf("conversion from %s to %s yields a string of one rune", source, target), + Message: fmt.Sprintf("conversion from %s to %s yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)", source, target), SuggestedFixes: []analysis.SuggestedFix{ { Message: "Did you mean to convert a rune to a string?", diff --git a/go/analysis/passes/stringintconv/testdata/src/a/a.go b/go/analysis/passes/stringintconv/testdata/src/a/a.go index 72ceb970cb..837469c194 100644 --- a/go/analysis/passes/stringintconv/testdata/src/a/a.go +++ b/go/analysis/passes/stringintconv/testdata/src/a/a.go @@ -25,12 +25,12 @@ func StringTest() { o struct{ x int } ) const p = 0 - _ = string(i) // want `^conversion from int to string yields a string of one rune$` + _ = string(i) // want `^conversion from int to string yields a string of one rune, not a string of digits \(did you mean fmt\.Sprint\(x\)\?\)$` _ = string(j) _ = string(k) - _ = string(p) // want `^conversion from untyped int to string yields a string of one rune$` - _ = A(l) // want `^conversion from C \(int\) to A \(string\) yields a string of one rune$` - _ = B(m) // want `^conversion from uintptr to B \(string\) yields a string of one rune$` - _ = string(n[1]) // want `^conversion from int to string yields a string of one rune$` - _ = string(o.x) // want `^conversion from int to string yields a string of one rune$` + _ = string(p) // want `^conversion from untyped int to string yields a string of one rune, not a string of digits \(did you mean fmt\.Sprint\(x\)\?\)$` + _ = A(l) // want `^conversion from C \(int\) to A \(string\) yields a string of one rune, not a string of digits \(did you mean fmt\.Sprint\(x\)\?\)$` + _ = B(m) // want `^conversion from uintptr to B \(string\) yields a string of one rune, not a string of digits \(did you mean fmt\.Sprint\(x\)\?\)$` + _ = string(n[1]) // want `^conversion from int to string yields a string of one rune, not a string of digits \(did you mean fmt\.Sprint\(x\)\?\)$` + _ = string(o.x) // want `^conversion from int to string yields a string of one rune, not a string of digits \(did you mean fmt\.Sprint\(x\)\?\)$` } diff --git a/go/analysis/passes/stringintconv/testdata/src/a/a.go.golden b/go/analysis/passes/stringintconv/testdata/src/a/a.go.golden index 9538a0132f..593962d7a9 100644 --- a/go/analysis/passes/stringintconv/testdata/src/a/a.go.golden +++ b/go/analysis/passes/stringintconv/testdata/src/a/a.go.golden @@ -25,12 +25,12 @@ func StringTest() { o struct{ x int } ) const p = 0 - _ = string(rune(i)) // want `^conversion from int to string yields a string of one rune$` + _ = string(rune(i)) // want `^conversion from int to string yields a string of one rune, not a string of digits \(did you mean fmt\.Sprint\(x\)\?\)$` _ = string(j) _ = string(k) - _ = string(rune(p)) // want `^conversion from untyped int to string yields a string of one rune$` - _ = A(rune(l)) // want `^conversion from C \(int\) to A \(string\) yields a string of one rune$` - _ = B(rune(m)) // want `^conversion from uintptr to B \(string\) yields a string of one rune$` - _ = string(rune(n[1])) // want `^conversion from int to string yields a string of one rune$` - _ = string(rune(o.x)) // want `^conversion from int to string yields a string of one rune$` + _ = string(rune(p)) // want `^conversion from untyped int to string yields a string of one rune, not a string of digits \(did you mean fmt\.Sprint\(x\)\?\)$` + _ = A(rune(l)) // want `^conversion from C \(int\) to A \(string\) yields a string of one rune, not a string of digits \(did you mean fmt\.Sprint\(x\)\?\)$` + _ = B(rune(m)) // want `^conversion from uintptr to B \(string\) yields a string of one rune, not a string of digits \(did you mean fmt\.Sprint\(x\)\?\)$` + _ = string(rune(n[1])) // want `^conversion from int to string yields a string of one rune, not a string of digits \(did you mean fmt\.Sprint\(x\)\?\)$` + _ = string(rune(o.x)) // want `^conversion from int to string yields a string of one rune, not a string of digits \(did you mean fmt\.Sprint\(x\)\?\)$` }