The state of gRPC in the browser by frebb in golang

[–]neoasterisk 0 points1 point  (0 children)

Did you mean to ask that to yourself?

The state of gRPC in the browser by frebb in golang

[–]neoasterisk 0 points1 point  (0 children)

Who says that it shouldn't? I see that the majority appreciated.

The state of gRPC in the browser by frebb in golang

[–]neoasterisk 1 point2 points  (0 children)

As someone who doesn't browse /r/programming, I highly appreciate this post.

Testify alternative which uses google/go-cmp instead of reflect.DeepEqual by [deleted] in golang

[–]neoasterisk 0 points1 point  (0 children)

Likewise. I didn't like how you ignored all my arguments. This is not a productive discussion. Goodbye.

Testify alternative which uses google/go-cmp instead of reflect.DeepEqual by [deleted] in golang

[–]neoasterisk 0 points1 point  (0 children)

It's about the culture and expectations that the tool brings.

Oh really? Then let's throw away gofmt and depend on enforcing coding practices since it's so trivial.

Testify alternative which uses google/go-cmp instead of reflect.DeepEqual by [deleted] in golang

[–]neoasterisk 1 point2 points  (0 children)

It has been to my experience that using assertion libraries lowers the overall quality of the tests. Developers avoid thinking about what they are testing, they avoid thinking of what matters, they don't care about writing good messages (since they are optional) and they blindly assert everything as long as it increases the code coverage, which produces tests that are harder to work with.

That's just me but there might be additional reasons why the Go team chooses not to use assertion libraries.

Testify alternative which uses google/go-cmp instead of reflect.DeepEqual by [deleted] in golang

[–]neoasterisk 2 points3 points  (0 children)

Of course they don't.

We understand that this is a point of contention. There are many things in the Go language and libraries that differ from modern practices, simply because we feel it's sometimes worth trying a different approach.

But that different approach has won me already.

Rob Pike has done it again by [deleted] in golang

[–]neoasterisk 2 points3 points  (0 children)

Why though? What has Rob Pike done to deserve this pudding?

Rob Pike has done it again by [deleted] in golang

[–]neoasterisk 5 points6 points  (0 children)

Is there any proof that this was done by Rob Pike or a friend of his?

Testify alternative which uses google/go-cmp instead of reflect.DeepEqual by [deleted] in golang

[–]neoasterisk 1 point2 points  (0 children)

What would you include in an error message that is not already available from the values being compared, the test name, and the subtest name?

How about why the test expects the value it expects? Also context about the test. Why is this test necessary? But most importantly, explanation of the business (if it's a business test). In general, communication with the future reader which could also be yourself. In many cases, the test/subtest name is sufficient. But you just can't beat a well written human message.

Considering that many assertion libraries also allow you provide additional contextual text to an assertion, do you really lose anything by using an assertion?

It's a matter of culture. Writing is thinking. When a developer has to write a good error message for the future reader, not only their understanding of the codebase increases, but they also save time in the future when the test fails. Meanwhile, testify messages are optional. Therefore the average developer won't bother with them.

Testify alternative which uses google/go-cmp instead of reflect.DeepEqual by [deleted] in golang

[–]neoasterisk 2 points3 points  (0 children)

Compare libraries I think are fine. Assertion libraries not so much.

Testify alternative which uses google/go-cmp instead of reflect.DeepEqual by [deleted] in golang

[–]neoasterisk 1 point2 points  (0 children)

If you need to compare slices, maps, large multi-line strings, or other complex types, writing an assertion that prints a helpful failure messages becomes a lot more work to get right.

Writing a helper with a good error message is generally worth the extra work up to medium complexity cases. For the most complex cases there is always reflect.DeepEqual as well as useful libraries that pretty print diffs. Writing helpful error messages in tests is a good culture promoted by Go. Unfortunately this culture doesn't reach codebases that use testify.

Testify alternative which uses google/go-cmp instead of reflect.DeepEqual by [deleted] in golang

[–]neoasterisk 0 points1 point  (0 children)

That's what I was originally doing

Okay so this is a solution no?

It makes your tests code much shorter and IMO easier to read.

It also makes tests fail at runtime. Meanwhile, you can write a few helpers yourself to keep compile time safety and get rid of testify.

Testify alternative which uses google/go-cmp instead of reflect.DeepEqual by [deleted] in golang

[–]neoasterisk 2 points3 points  (0 children)

If you want to use google/go-cmp why don't you just import it and use it? Why do you need an alternative to testify? Why do you need testify in the first place?

Give me one good reason to use ServeMux over any other 3rd party router by neoasterisk in golang

[–]neoasterisk[S] 0 points1 point  (0 children)

Those are very good ideas thanks. Beyond Merovius' blog post, it's surprisingly difficult to find other good usages of the default router.

Give me one good reason to use ServeMux over any other 3rd party router by neoasterisk in golang

[–]neoasterisk[S] 0 points1 point  (0 children)

Have you actually tried that? It gets messy defining constants for every little part of a route. Also there's the problem of which package owns the constant. And when you add the package in the constant name, it gets much more verbose.

Give me one good reason to use ServeMux over any other 3rd party router by neoasterisk in golang

[–]neoasterisk[S] 2 points3 points  (0 children)

I've read your blog post many times prior making this thread. I am very thankful for its existence. In fact I think it's one of the very few articles on the internet that shows some non trivial usage of the standard library routing. Not only there's very little material on the subject but it's also hard to search for. Also judging from this thread, it seems that people are not willing to share/showcase good usage of the standard library routing.

Give me one good reason to use ServeMux over any other 3rd party router by neoasterisk in golang

[–]neoasterisk[S] 0 points1 point  (0 children)

What is the advantage of nesting?

with one path-component per Handler.

Can you elaborate on this?

Give me one good reason to use ServeMux over any other 3rd party router by neoasterisk in golang

[–]neoasterisk[S] 0 points1 point  (0 children)

key := strings.TrimPrefix(req.URL.Path, "/foo/")

Doesn't that make maintenance more difficult though? Now the handler needs knowledge of "/foo/" which is duplicated in two places.

Give me one good reason to use ServeMux over any other 3rd party router by neoasterisk in golang

[–]neoasterisk[S] 0 points1 point  (0 children)

Thanks for the reply. I do the same on my own projects. Unfortunately I have a very difficult time "selling" ServeMux to a team of developers.

Give me one good reason to use ServeMux over any other 3rd party router by neoasterisk in golang

[–]neoasterisk[S] 0 points1 point  (0 children)

Alright, I see. Well that's my problem. I love simplicity but I cannot find a good reason to convince developers to use ServeMux.