In code that uses Go reflection, it is common that the user prints the type. However, it easy for people (out of habit) to use %T with a reflect.Type when they should actually be using %v instead.
panic(fmt.Sprintf("invalid type: %T", t)) // incorrect: should be using %v
It is unlikely that the wrong verb is detected during code review.
In the instances similar to this, I don't think I saw a single case where a person actually wanted to print the type of reflect.Type itself (which by the way is *reflect.rtype and not particularly interesting for users).
\cc @dominikh in case this is a check better suited for staticcheck than vet.
The text was updated successfully, but these errors were encountered:
I think this would be fine for precision and correctness. I'm less sure about frequency; how often does this bug come up in practice? I think I've seen this bug maybe once or twice before, which makes me think it would be significantly less frequent than a lot of the other vet checks, but perhaps my experience is biased.