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.
For example:
t := reflect.TypeOf(...)
if checkValid(t) {
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.
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.Typewhen they should actually be using%vinstead.For example:
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.Typeitself (which by the way is*reflect.rtypeand not particularly interesting for users).\cc @dominikh in case this is a check better suited for
staticcheckthan vet.