Discussion about this post

User's avatar
Glenn Lewis's avatar

Very nice, thank you!

For # 1.5, I would just add `t.Helper()` as the first line of `handleDBConnection`.

For # 3, this is also sometimes called the "Builder" pattern, and if any of the steps could cause an error, but you still want the simplicity of chaining, you can add a `Build` or `Do` method at the end of the chain that returns one or more values, including a (potentially "joined") error (typically accumulated during the building of the chain).

I use this builder pattern here, for example: https://github.com/gmlewis/go-bjk/blob/master/examples/bifilar-electromagnet/main.go#L155

Expand full comment
LB's avatar

Nice list, I've learned a few things, thanks! One question: the link https://medium.com/@func25/go-performance-boosters-the-top-5-tips-and-tricks-you-need-to-know-e5cf6e5bc683 is behind paywall, do you have a copy somewhere else?

Expand full comment
3 more comments...

No posts