Debian Codegraph @

staticcheck/sa1006/testdata/go1.0/CheckUnsafePrintf/CheckUnsafePrintf.go.golden

raw
1 package pkg
2
3 import (
4 "fmt"
5 "log"
6 "os"
7 "testing"
8 )
9
10 func fn(s string) {
11 fn2 := func() string { return "" }
12 fmt.Print(fn2()) //@ diag(`should use print-style function`)
13 _ = fmt.Sprint(fn2()) //@ diag(`should use print-style function`)
14 log.Print(fn2()) //@ diag(`should use print-style function`)
15 fmt.Print(s) //@ diag(`should use print-style function`)
16 fmt.Printf(s, "")
17 fmt.Fprint(os.Stdout, s) //@ diag(`should use print-style function`)
18 fmt.Fprintf(os.Stdout, s, "")
19
20 fmt.Printf(fn2(), "")
21 fmt.Printf("")
22 fmt.Printf("%s", "")
23 fmt.Printf(fn3())
24
25 l := log.New(os.Stdout, "", 0)
26 l.Printf("xx: %q", "yy")
27 l.Print(s) //@ diag(`should use print-style function`)
28
29 var t testing.T
30 t.Log(fn2()) //@ diag(`should use print-style function`)
31 t.Error(s) //@ diag(`should use print-style function`)
32 t.Fatal(s) //@ diag(`should use print-style function`)
33 t.Skip(s) //@ diag(`should use print-style function`)
34
35 var b testing.B
36 b.Log(fn2()) //@ diag(`should use print-style function`)
37 b.Error(s) //@ diag(`should use print-style function`)
38 b.Fatal(s) //@ diag(`should use print-style function`)
39 b.Skip(s) //@ diag(`should use print-style function`)
40
41 var tb testing.TB
42 tb.Log(fn2()) //@ diag(`should use print-style function`)
43 tb.Error(s) //@ diag(`should use print-style function`)
44 tb.Fatal(s) //@ diag(`should use print-style function`)
45 tb.Skip(s) //@ diag(`should use print-style function`)
46
47 errors.New(s) //@ diag(`should use print-style function`)
48
49 var nested struct {
50 l log.Logger
51 }
52 nested.l.Print(s) //@ diag(`should use print-style function`)
53 }
54
55 func fn3() (string, int) { return "", 0 }