News for hackers. Stuff that matters.
Re:Effective Go by deanCommie on Sunday October 03, 2021 @11:37AM (#28737993)
From what I understand (from making similar complaints to Gophers), if you're complaining about boilerplate, you don't get it.

The boilerplate propagation is the point in Go.

Go isn't DRY. Go would rather copy and paste a bunch of code than introduce the "complexity" of inheritance.

Re:Effective Go by mxz3000 on Sunday October 03, 2021 @12:17PM (#28738265)
But you can obviously DRY without inheritance?

I'm not sure that Go pushes you to duplicate code... Do you mean copy a slightly tweak code for different use cases and types ?

Re:Effective Go by closeparen on Sunday October 03, 2021 @11:46AM (#28738055)
I am okay with the level of abstraction available in production code. Where it gets ridiculous is the tests. Unit testing the simplest, most obvious Go code is a huge chore. Each error-returning function call costs 15 seconds to type but 15 minutes to work into the tests.
Re:Effective Go by ed25519FUUU on Sunday October 03, 2021 @11:56AM (#28738133)
There is unnecessary friction, which doesn’t really seem to fit with the Go ethos. I would have assumed from afar that testing gets a lot of consideration in a language like Go.
Re:Effective Go by alecthomas on Sunday October 03, 2021 @02:54PM (#28739588)
It does. It sounds like the parent has had an unfortunate interaction with a bad codebase, because that is not accurate at all.
Re:Effective Go by closeparen on Sunday October 03, 2021 @02:58PM (#28739613)
I am not being sarcastic when I say I want an "Effective Go" for this. If you have examples of high quality tests in an MVC-style service codebase, I would love to see them!
Re:Effective Go by alecthomas on Sunday October 03, 2021 @08:00PM (#28741629)
Others have recommended Advanced Testing With Go [1]. I haven't personally watched it, but Mitchell Hashimoto writes clean code.

But if you'd like I'd be happy to take a look at some of the problems you're encountering. I'm @alecthomas on the Gophers Slack or Twitter, feel free to DM me. No guarantees, but it sounds very unusual for an additional test to consume 15 minutes of setup.

[1] https://www.youtube.com/watch?v=8hQG7QlcLBk

Re:Effective Go by sagichmal on Sunday October 03, 2021 @06:14PM (#28740967)
"MVC" is not an idiomatic pattern in Go.
Re:Effective Go by morelisp on Monday October 04, 2021 @07:40AM (#28745433)
"MVC" is at least a half dozen different patterns at this point, and at least one - the one the closeparen is talking about, rendering responses to incoming requests out parts of a data store - is pretty common in Go.

What's different is that the "model" is often e.g. a bare sql.DB and not an object repository, and the "view" is a template called directly by the controller, but "MVC" - even this kind, which isn't the original kind - doesn't have to be an auto-wired DI interface-laden mess. PHP and Java just made it that way.

Re:Effective Go by closeparen on Sunday October 03, 2021 @10:40PM (#28742441)
Maybe it would pay to be more specific, since "MVC" can mean a lot of things. We have requests come into handlers, which map between wire and internal representations. They invoke controllers, which implement the business logic and call gateways and repositories. Repositories wrap storage clients and gateways wrap HTTP or gRPC clients.

Do you not do this? What do you do instead? I guess I can see how testing would be less painful with fewer layers, but at the cost of the production code becoming more entangled.

Re:Effective Go by sagichmal on Monday October 04, 2021 @09:01AM (#28746111)
When I read MVC I guess I take it pretty literally, in that you would have packages named model/s, view/s, and controller/s. That's what I'm speaking to. Of course, abstractly, many programs tend to be structured in some kind of layering scheme that's MVC-ish :)
Re:Effective Go by alecthomas on Sunday October 03, 2021 @08:00PM (#28741635)
Assuming the parent is being genuine in asking for help, I don't think is a very constructive response.
Re:Effective Go by sagichmal on Sunday October 03, 2021 @09:11PM (#28741992)
I don't understand why you would reply with this comment. If the question is "how do I do X?" and X isn't something that you should be doing, why is it not constructive to point that out?