Why is rune in golang an alias for int32 and not uint32?

前端 未结 5 2093
我寻月下人不归
我寻月下人不归 2021-01-31 15:10

The type rune in Go is defined as

an alias for int32 and is equivalent to int32 in all ways. It is used, by conv

5条回答
  •  清歌不尽
    2021-01-31 15:24

    I googled and found this

    This has been asked several times. rune occupies 4 bytes and not just one because it is supposed to store unicode codepoints and not just ASCII characters. Like array indices, the datatype is signed so that you can easily detect overflows or other errors while doing arithmetic with those types.

提交回复
热议问题