Comment by nikolayasdf123
Comment by nikolayasdf123 13 hours ago
> wg := sync.WaitGroup{}
just `var wg sync.WaitGroup`, it is cleaner this way
Comment by nikolayasdf123 13 hours ago
> wg := sync.WaitGroup{}
just `var wg sync.WaitGroup`, it is cleaner this way
no. it is different thing. container-agnostic zero value vs struct init.
multiple 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.
hold 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
"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
zero 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#declar...
That 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.
doesn't this point to a bigger problem that there are two ways of doing the same thing?