Linter to follow practices described in TestComments #6446
-
|
Hi! I’ve created a new linter that checks for several practices recommended in the official Go TestComments guidelines. I am sharing it here to get feedback and check whether people are interested in using it, and if so, add it to golangci-lint. The linter, currently, performs the following checks:
Suggests replacing them with the more robust
Error messages should include the function name (as recommended in the guideline on identifying the function) and verifies that when both values are printed, got appears before want (got-before-want).
Can be configured to enforce consistent usage of |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
This wiki page is not something I, personally, either want to follow or recommend. It feels like a rant against But in the reality:
I fully understand that the Go team doesn't like it because this is not their way to handle the topic. My personal opinion is that gophers by using libraries are drawing a desire path, and it's useless to fight against a massive desire path like this one about tests assertions. |
Beta Was this translation helpful? Give feedback.
This wiki page is not something I, personally, either want to follow or recommend.
It feels like a rant against
testifyusage with instructions to recreate it.But in the reality:
testifyis better, at the usage, than the std library, because you don't have to reinvent the wheel for each project, and the syntax is more readable, and less verbose.testifyis used everywhere: https://blog.thibaut-rousseau.com/blog/the-most-popular-go-dependency-is/I fully understand that the Go team doesn't like it because this is not their way to handle the topic.
But we can think to other topic like HTTP router: before they changed the std router syntax, a library was require if you didn't want to rein…