You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Your code fragment doesn't compile: "11: syntax error near go".
In your example, the Go for statement executes as expected; it executes an infinite
loop, as it would in most languages.
http://golang.org/doc/go_spec.html#For_statements
In Go, byte is an alias for uint8, with a range of 0 through +255.
http://golang.org/doc/go_spec.html#Numeric_types
In Go, unsigned integer operations discard high bits upon overflow.
http://golang.org/doc/go_spec.html#Integer_overflow
In the for loop, after i reaches +255, the i++ statement increments it to +266 and
then discards the overflowing high order bits, leaving a byte (uint8) value of zero.
The for statement cycles the loop variable i through the range 0 to +255 forever.
If you change the for statement condition from i <= 255 to i < 255, the loop will
terminate.
Questions about language usage, as opposed to confirmed bugs, are best posed in the
Go Nuts mailing list.
Assuming the bug report is about the fact that the
loop never stops, yes, that's correct behavior,
because every possible byte value is <= 255, so
i <= 255 is always true.
by graycardinalster:
The text was updated successfully, but these errors were encountered: