package main
import "fmt"
func main() {
_ = fmt.Sprintf("You say %[1]s, I also say %[1]s", "hello")
}
Using the version before the PR mentioned above, there is no change as positional arguments weren't supported.
$ go install github.com/catenacyber/perfsprint@v0.4.0
$ perfsprint --fix ./...
Using a the latest version (i.e. after the PR was merged) it detects and gives an inccorrect suggested "fix":
$ go install github.com/catenacyber/perfsprint@v0.7.0
$ perfsprint --fix ./...
test/main.go:6:7: fmt.Sprintf can be replaced with string concatenation
test/main.go:3:8: Fix imports
The fix is:
package main
import
func main() {
_ = "You say %[1]s, I also say "+"hello"
}
Given this is not a simple concatenation I would expect this to just not be flagged by perfsprint.
https://github.com/catenacyber/perfsprint/pull/16 fails to consider cases where the one arguments is referenced multiple times:
Using the version before the PR mentioned above, there is no change as positional arguments weren't supported.
Using a the latest version (i.e. after the PR was merged) it detects and gives an inccorrect suggested "fix":
The fix is:
Given this is not a simple concatenation I would expect this to just not be flagged by perfsprint.