4 ms·
> wg := sync.WaitGroup{} just `var wg sync.WaitGroup`, it is cleaner this way
by nikolayasdf123 1y ago
> wg := sync.WaitGroup{}
just `var wg sync.WaitGroup`, it is cleaner this way
- mr90210 1y agoOh you are one of those. The nit picker. This is not at a PR review mate.
- nikolayasdf123 1y ago"one of those", name calling, telling me what to say, cool it down a little. touch some grass. and hopefully you will see beauty in Go zero-values :P
- dwb 1y agoWhy?
- nikolayasdf123 1y agozero value. container-agnostic initialization. say your type is not struct anymore, you would not have to change the way you intialize it. what you care here is zero value, and let the type figure out that it is zero and use methods appropriately. and it is just more clean this way here is google guideline: https://google.github.io/styleguide/go/best-practices#declaring-variables-with-zero-values https://google.github.io/styleguide/go/best-practices#declar...
- dwb 1y agoThat is a much better argument than saying it is "more clean", which doesn't mean anything. I don't necessarily agree, because I don't think zero values are a good feature of the language, and even if they were this is a completely trivial case. But at least I don't have to work out what "cleanliness" is.
- fozdenn 1y agodoesn't this point to a bigger problem that there are two ways of doing the same thing?
- nikolayasdf123 1y agono. it is different thing. container-agnostic zero value vs struct init.
- unsnap_biceps 1y agomultiple ways of doing something isn't inherently bad. For example, if you want to set a variable to the number of seconds in seven hours, you could just set the variable to 25200, or you could set it to 60 * 60 * 7. The expanded version might be clearer in the code context, but in the end they do exactly the same thing.
- pests 1y agoYour math equation turned the asterisks into italics.
- unsnap_biceps 1y agoWhoops, fixed. Thanks for the note
- nikolayasdf123 1y agohold on, why would you have 7 hours? dont you mean a week? 60 x 60 x 24 x 7 ? or at lest 8 hours? 7 hours is just odd
- unsnap_biceps 1y agoThe goal was to pick an arbitrary number that wasn't well known. There was no intention behind the specific value chosen.