What is the correct format specifier to print error object in Go: %s or %v?

According to docs:

%v  the value in a default format
...
%s  the uninterpreted bytes of the string or slice

Also, more information about error:

The error type is an interface type. An error variable represents any
value that can describe itself as a string.

So, treat it as %s.

Leave a Comment