rune is alias of int32

时间:2022-05-18 03:30:38

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 uints, 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). ints 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://*.com/questions/24714665/why-is-rune-in-golang-an-alias-for-int32-and-not-uint32