I think chendesheng‘s quote gets at the root cause best: Go uses a lot of signed values, not just for runes but array indices, Read
/Write
byte counts, etc. That‘s because uint
s, in any language, behave confusingly unless you guard every piece of arithmetic against overflow (for example if var a, b uint = 1, 2
, a-b > 0
and a-b > 1000000
: play.golang.org/p/lsdiZJiN7V). int
s behave more like numbers in everyday life, which is a compelling reason to use them, and there is no equally compelling reason not to use them.
http://stackoverflow.com/questions/24714665/why-is-rune-in-golang-an-alias-for-int32-and-not-uint32
时间: 2024-10-21 23:57:35