The check.Comment type does not implement fmt.Stringer. The Error* and Fail* functions do not support check.Comment values. This means that we currently need:
The simplest change is probably to implement Comment#String, which then allows:
c.Errorf("unexpected callback: %s", comment)
The trouble with this approach is that existing implementations of CommentInterface outside the check package would not see the benefit without adding a String implementation. Maybe that's not much of an issue, as they're probably already calling CheckCommentString directly to support Error* and Fail* calls.
Alternatively, the Error* and Fail* functions could peek at their last argument to see if it implements CommentInterface. Comments would be handled in a similar way to what happens in internalCheck to support Check and Assert.
The
check.Comment
type does not implementfmt.Stringer
. TheError*
andFail*
functions do not supportcheck.Comment
values. This means that we currently need:The simplest change is probably to implement
Comment#String
, which then allows:The trouble with this approach is that existing implementations of
CommentInterface
outside thecheck
package would not see the benefit without adding aString
implementation. Maybe that's not much of an issue, as they're probably already callingCheckCommentString
directly to supportError*
andFail*
calls.Alternatively, the
Error*
andFail*
functions could peek at their last argument to see if it implementsCommentInterface
. Comments would be handled in a similar way to what happens ininternalCheck
to supportCheck
andAssert
.