I’ve found an interesting behavior of go vet with sprintf which I would not expect (it’s inside the lint check).
For this check, I get a violation: fmt.Sprintf("%[1]s%[2]s", "foo")
When I pass more arguments into Sprintf than expected, everything is fine from go vet perspective:
fmt.Sprintf("%[1]s", "foo", "bar")
Could you explain me why go vet is not throwing a violation in this case? I’d expect it should also cover this case as developer might forget to update the formatting string. Or, at least to have a possibility to turn this kind of check on by configuration.
I’m only guessing but I think the difference is because the first code can potentially panic in production while the second don’t.
It’s more “expected parameter” vs “unused parameter”