go-errorlint icon indicating copy to clipboard operation
go-errorlint copied to clipboard

Allow `%T` verb

Open MigratoryCoconuts opened this issue 1 year ago • 1 comments

when attempting to unmarshall json (or similar) into a type that implements error, we would like to print failures alongside the type that our unmarshalling failed against. an example in our codebase is here:

err = dec.Decode(&pErr)
if err != nil {
	return nil, fmt.Errorf("%v is not a %T: %w", traceBody.String(), pErr, err)
}

this gets falsly flagged by this linter. the meanings and semantics of %T are significantly different from other verbs, and it should be ignored

MigratoryCoconuts avatar Aug 09 '24 18:08 MigratoryCoconuts

Agreed. Thanks for raising this

polyfloyd avatar Sep 02 '24 12:09 polyfloyd