by gizzlon · 7y ago · 0 comments
Solutions like this, more abstraction to avoid repetitive code, are usually much worse than the problem.
> Though we notice we only greet for mornings and afternoons so always having to pass “Good morning” or “Good afternoon” becomes a bit annoying.
Maybe? But one can do much much much worse than "a bit annoying"
> It would be great if we could create an instance of our “greet” function with the first argument pinned down.
No.
I feel like code even should be dumb most of the time and only clever when needed. The hard part is to figure out when to be clever.
While keeping things short is a goal, it's not the only goal..
That applies here too: if you find yourself writing too much boilerplate code in favor of an abstraction, try another language. If you want/have to continue in Go, look for another solution.