3 ms·
> since Go 1.22, every freshly-declared loop variable used in a for loop will be instantiated as a distinctive instance at the start of each iteration. In other
by kiitos 2y ago
> since Go 1.22, every freshly-declared loop variable used in a for loop will be instantiated as a distinctive instance at the start of each iteration. In other words, it is per-iteration scoped now. So the values of the i and v loop variables used in the two new created goroutines are 1 2 and 3 4, respectively. (1+2) + (3+4) gives 10.
I think you are assuming more guarantees than are actually guaranteed.
You have a well-documented history of making incorrect claims about Go compiler and runtime behaviors, so this isn't surprising.
> since Go 1.22, you should try to specify a Go language version for every Go source file
What on Earth?? Absolutely 100% not.
- tapirl 2y ago:D It looks you don't understand the change at all. The statement "since Go 1.22, you should try to specify a Go language version for every Go source file" is made officially, not by me. > You have a well-documented history of making incorrect claims about Go compiler and runtime behaviors, so this isn't surprising. The claim is totally baseless. All my opinions and articles are based on facts. If you have found ones which are incorrect or which are not based on facts, please let me know: https://x.com/zigo_101 https://x.com/zigo_101.
- kiitos 2y ago> The statement "since Go 1.22, you should try to specify a Go language version for every Go source file" is made officially, not by me. Please provide a link to documentation on golang.org. Note: not a comment in a GitHub issue, not a blog article -- official stuff only. > baseless It should be evident by the consistent responses to your GitHub issues that nobody takes you seriously. Which is unsurprising, when you make recommendations like > Anyway, since Go 1.22, you should try to specify a Go language version for every Go source file, in any of the above introduced ways, to avoid compiler version dependent behaviors. This is the minimum standard to be a professional Go programmer in the Go 1.22+ era.