Hacker News new | ask | show | jobs
by liampulles 294 days ago
The "Go-ithic" way to write a library is to be strict with its API and place the onus on the consumer to do the work to map to and from it. So if I understand your example correctly (I might not), then it would be totally acceptable and in fact preferable for a Go codebase to map between the validator, then the query builder, and then the http response. Its preferable because I want libraries to have a thin API and be focused on doing one thing well, and I also want to have it clearly presented to me how I am mapping to and from an external dependency.

Another way of putting is that the Go philosophy is not to abstract details away or try and hide them, its to make the actual control flow of the program as plain and obvious as possible.

1 comments

I understand that is the Go philosophy. I care more about what is practical than dogmatic. It seems clear to me as a complex library author that the type system leads to way too much glue code, which is expensive to write and maintain.
As a Go developer of a few years now, I don't find it that way. I've found it to be very easy to write the glue code, because its largely the same as other glue code, and I find it easy to maintain because the plain control flow makes finding bugs easy. But perhaps the takeaway here is that, because Go certainly is opinionated, its a way of doing business that works for some and not others. And that's cool.