stretchr/testify

consider using String() method on types that implement fmt.Stringer

Open

#1,215 创建于 2022年6月24日

在 GitHub 查看
 (2 评论) (3 反应) (0 负责人)Go (25,958 star) (1,704 fork)batch import
help wantedinput neededpkg-assert

描述

First of all, thanks for this great library! We use it quite extensively in go-libp2p.

We're running into the problem that the error output is unreadable for many types.

For example, we have a type peer.ID that's just a string (type peer.ID string), but the error output is practically unreadable:

Error:      	[]peer.ID{"\x12 \x92\xad \xd38\r\xadG\xf4\xd57\xee\xe5B\xa6\xffk\x80\xb2\xdda\xe5&\a\xc69\x80>D=\xfc}", "\x12 \f5;\xd7\xca\x12\xe6\x8cɷ\x00\xa71\x85\xb7|\x8brGO\xb2\xb0\xf9\xaa\"A\xee\xd3#eHH", "\x12 \xa8q3O\xd00\x16\x83JA\xa2L\x1e\xed2\x9a\xf87\x01~\xf8ڗ\x97\xdaT\xb1\xe2(\x89\xba\x15", "\x12 \xa3\xbb\xcb`\x8cV\xbb@Z\xd8%\xb3|}K\x90\a\xa7\xb5\xdeg\u0600|ʿ籐7\x8e\xc8"} does not contain "\x12 \xfd\x97\xf2?\x85?&\xc22el;\xac\xa4m\x1cj\xa4\xe3c\xcf\x00\x85u\xdb}:~3\xbf\x81\xaa"

Another example is a type that contains a byte slice, but has a nice string representation. But instead of using that one, require error message print the byte slice.

I'd be happy to contribute a PR, if this is something you would consider accepting.

贡献者指南