|
| 1 | +//golangcitest:args -Eperfsprint |
| 2 | +//golangcitest:config_path testdata/configs/perfsprint_int_conversion.yml |
| 3 | +package testdata |
| 4 | + |
| 5 | +import ( |
| 6 | + "fmt" |
| 7 | +) |
| 8 | + |
| 9 | +func TestPerfsprint2() { |
| 10 | + var ( |
| 11 | + s string |
| 12 | + err error |
| 13 | + b bool |
| 14 | + i int |
| 15 | + i64 int64 |
| 16 | + ui uint |
| 17 | + ) |
| 18 | + |
| 19 | + fmt.Sprintf("%s", s) // want "fmt.Sprintf can be replaced with just using the string" |
| 20 | + fmt.Sprint(s) // want "fmt.Sprint can be replaced with just using the string" |
| 21 | + fmt.Sprintf("%s", err) // want "fmt.Sprintf can be replaced with err.Error()" |
| 22 | + fmt.Sprint(err) // want "fmt.Sprint can be replaced with err.Error()" |
| 23 | + fmt.Sprintf("%t", b) // want "fmt.Sprintf can be replaced with faster strconv.FormatBool" |
| 24 | + fmt.Sprint(b) // want "fmt.Sprint can be replaced with faster strconv.FormatBool" |
| 25 | + fmt.Sprintf("%d", i) // want "fmt.Sprintf can be replaced with faster strconv.Itoa" |
| 26 | + fmt.Sprint(i) // want "fmt.Sprint can be replaced with faster strconv.Itoa" |
| 27 | + fmt.Sprintf("%d", i64) // want "fmt.Sprintf can be replaced with faster strconv.FormatInt" |
| 28 | + fmt.Sprint(i64) // want "fmt.Sprint can be replaced with faster strconv.FormatInt" |
| 29 | + fmt.Sprintf("%d", ui) |
| 30 | + fmt.Sprint(ui) |
| 31 | + fmt.Sprintf("%x", []byte{'a'}) // want "fmt.Sprintf can be replaced with faster hex.EncodeToString" |
| 32 | + fmt.Errorf("hello") // want "fmt.Errorf can be replaced with errors.New" |
| 33 | + fmt.Sprintf("Hello %s", s) // want "fmt.Sprintf can be replaced with string addition" |
| 34 | + |
| 35 | + fmt.Sprint("test", 42) |
| 36 | + fmt.Sprint(42, 42) |
| 37 | + fmt.Sprintf("test") |
| 38 | + fmt.Sprintf("%v") |
| 39 | + fmt.Sprintf("%d") |
| 40 | + fmt.Sprintf("%d", 42, 42) |
| 41 | + fmt.Sprintf("%#d", 42) |
| 42 | + fmt.Sprintf("value %d", 42) |
| 43 | + fmt.Sprintf("val%d", 42) |
| 44 | + fmt.Sprintf("%s %v", "hello", "world") |
| 45 | + fmt.Sprintf("%#v", 42) |
| 46 | + fmt.Sprintf("%T", struct{ string }{}) |
| 47 | + fmt.Sprintf("%%v", 42) |
| 48 | + fmt.Sprintf("%3d", 42) |
| 49 | + fmt.Sprintf("% d", 42) |
| 50 | + fmt.Sprintf("%-10d", 42) |
| 51 | + fmt.Sprintf("%[2]d %[1]d\n", 11, 22) |
| 52 | + fmt.Sprintf("%[3]*.[2]*[1]f", 12.0, 2, 6) |
| 53 | + fmt.Sprintf("%d %d %#[1]x %#x", 16, 17) |
| 54 | +} |
0 commit comments