github.com/cockroachdb/tools@v0.0.0-20230222021103-a6d27438930d/go/analysis/passes/printf/testdata/src/b/b.go (about)

     1  package b
     2  
     3  import "fmt"
     4  
     5  // Wrapf is a printf wrapper.
     6  func Wrapf(format string, args ...interface{}) { // want Wrapf:"printfWrapper"
     7  	fmt.Sprintf(format, args...)
     8  }
     9  
    10  // Wrap is a print wrapper.
    11  func Wrap(args ...interface{}) { // want Wrap:"printWrapper"
    12  	fmt.Sprint(args...)
    13  }
    14  
    15  // NoWrap is not a wrapper.
    16  func NoWrap(format string, args ...interface{}) {
    17  }
    18  
    19  // Wrapf2 is another printf wrapper.
    20  func Wrapf2(format string, args ...interface{}) string { // want Wrapf2:"printfWrapper"
    21  
    22  	// This statement serves as an assertion that this function is a
    23  	// printf wrapper and that calls to it should be checked
    24  	// accordingly, even though the delegation below is obscured by
    25  	// the "("+format+")" operations.
    26  	if false {
    27  		fmt.Sprintf(format, args...)
    28  	}
    29  
    30  	// Effectively a printf delegation,
    31  	// but the printf checker can't see it.
    32  	return fmt.Sprintf("("+format+")", args...)
    33  }