github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/staticcheck/sa1006/testdata/src/example.com/CheckUnsafePrintf/CheckUnsafePrintf.go (about)

     1  package pkg
     2  
     3  import (
     4  	"fmt"
     5  	"log"
     6  	"os"
     7  )
     8  
     9  func fn(s string) {
    10  	fn2 := func() string { return "" }
    11  	fmt.Printf(fn2())      //@ diag(`should use print-style function`)
    12  	_ = fmt.Sprintf(fn2()) //@ diag(`should use print-style function`)
    13  	log.Printf(fn2())      //@ diag(`should use print-style function`)
    14  	fmt.Printf(s)          //@ diag(`should use print-style function`)
    15  	fmt.Printf(s, "")
    16  	fmt.Fprintf(os.Stdout, s) //@ diag(`should use print-style function`)
    17  	fmt.Fprintf(os.Stdout, s, "")
    18  
    19  	fmt.Printf(fn2(), "")
    20  	fmt.Printf("")
    21  	fmt.Printf("%s", "")
    22  	fmt.Printf(fn3())
    23  }
    24  
    25  func fn3() (string, int) { return "", 0 }