Howdy,
I’ve discovered an fascinating habits of go vet
with sprintf which I might not anticipate (it’s contained in the lint test).
For this test, I get a violation:fmt.Sprintf("%[1]s%[2]s", "foo")
After I cross extra arguments into Sprintf
than anticipated, every part is ok from go vet
perspective:
fmt.Sprintf("%[1]s", "foo", "bar")
May you clarify me why go vet
will not be throwing a violation on this case? I’d anticipate it also needs to cowl this case as developer may overlook to replace the formatting string. Or, a minimum of to have a risk to show this type of test on by configuration.
Thanks for clarification.
Hello and welcome to the discussion board.
I’m solely guessing however I believe the distinction is as a result of the primary code can doubtlessly panic in manufacturing whereas the second don’t.
It’s extra “anticipated parameter” vs “unused parameter”
thanks for the reply.
I most likely overlook to say that when there are not any numbered arguments, go vet violates correctly an error:
fmt.Sprintf("%s", "foo", "bar")
Why there’s additionally not an error for numbered arguments?