DEV Community

Discussion on: 12 Personal Go Tricks That Transformed My Productivity

Collapse
 
teivah profile image
Teiva Harsanyi

Thanks for your post.

About 1., a slight variation that I even prefer if you don't need to return time.Duration: go.dev/play/p/D0qkU5zB1Co

Collapse
 
func25 profile image
Phuong Le

Hmm... that's a good one but just thinking, the "()()" might trip some folks up if they miss the second "()". Still, it's an excellent trick that I'd never thought of.

Collapse
 
teivah profile image
Teiva Harsanyi

You're right, that's something to consider before submitting such a code.

But yeah as it was a "tricks" post I thought that might be interesting :)

I also use it when in a function, I need to do a pre and post action: go.dev/play/p/J31oyRhJzQ-
It's pretty handy during testing, for example.

Thread Thread
 
func25 profile image
Phuong Le • Edited

Oh shoot, I see the benefit of this Teiva, it's really great for handling actions both before and after a function, could I possibly include this tip in the post?

By the way, do you think this trick can be safely applied in production?

Thread Thread
 
teivah profile image
Teiva Harsanyi

could I possibly include this tip in the post?

Sure, please

do you think this trick can be safely applied in production

Yes, there's nothing unsafe. The only caveat is that Go devs might be slightly confused at first when reading the code.