Well, it tells us about the Go programmers on the forum. One possibility is that as Go has become more mainstream, Go programmers have become less competent on average.
EDIT: the version I pasted below is not what I originally typed into the site. I made several errors while copy/pasting and modifying the code to run locally without a channel.
It told me I have an error ("what happens at zero") when i do:
func below(n uint64, to chan uint64) {
for n; n > 0; n-- {
to <- n-1
n--
}
close(to)
}
but running that function with several test inputs produces what I expected. Note, I removed the channel (replaced with println) as that doesn't add anything to the problem.
Note: I've been programming (including C and C++) for 3+ decades. I make mistakes all the time, but.... what exactly are you looking for here if my solution is not ruight?
EDIT: the pasted code is also incorrect, because I didn't complete converting the for loop into a while.
I also came to a solution very similar to the sibling comment here. I'd love to see why this doesn't work server-side but does work on my machine. What other tests are you running aside from checking each decrement is correct?
Might I recommend appropriate debugging output? It would save the mystery and back and forth. Not everyone who uses your site has access to you on HN. :)
func below(n uint64, to chan uint64) {
for ; n >= 0; n-- {
var t = n - 1
to <- n
}
close(to)
}
I've run this locally with to <- n replaced with a print statement and it works with unsigned integers.
(my real comment after I get some clarification from the bugfix site author is that I never, ever modify a variable in the initialization condition of a for loop, and i see that in the wild, I elide it.
A C programmer who understands a for loop should be able to fix this, despite the fact it's Go:
Maybe you're right: It could be that C programmers don't understand Go syntax and Go programmers tend to be less experienced.