| ▲ | nikolayasdf123 2 days ago |
| > wg := sync.WaitGroup{} just `var wg sync.WaitGroup`, it is cleaner this way |
|
| ▲ | mr90210 2 days ago | parent | next [-] |
| Oh you are one of those. The nit picker. This is not at a PR review mate. |
| |
| ▲ | nikolayasdf123 2 days ago | parent [-] | | "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 |
|
|
| ▲ | fozdenn 2 days ago | parent | prev | next [-] |
| doesn't this point to a bigger problem that there are two ways of doing the same thing? |
| |
| ▲ | nikolayasdf123 2 days ago | parent | next [-] | | no. it is different thing. container-agnostic zero value vs struct init. | |
| ▲ | unsnap_biceps 2 days ago | parent | prev [-] | | 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. | | |
| ▲ | pests 2 days ago | parent | next [-] | | Your math equation turned the asterisks into italics. | | | |
| ▲ | nikolayasdf123 2 days ago | parent | prev [-] | | 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 | | |
| ▲ | unsnap_biceps a day ago | parent [-] | | The goal was to pick an arbitrary number that wasn't well known. There was no intention behind the specific value chosen. |
|
|
|
|
| ▲ | dwb 2 days ago | parent | prev [-] |
| Why? |
| |
| ▲ | nikolayasdf123 2 days ago | parent [-] | | 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... | | |
| ▲ | dwb 2 days ago | parent [-] | | 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. |
|
|