您的位置 首页 golang

golang中数字字段的类型约定

  • 我们常见的字段类型:有符号的:int,int8,int16,int32,int64;无符号的:uint8,uint16,uint32,uint64;其中int跟具体机器环境有关,表示32位或者64位有符号整型
  • 取值范围:
    • int32: -2147483648~2147483647
    • int64: -9223372036854775808~9223372036854775807
    • uint32: 0~4294967295
    • uint64: 0~18446744073709551615
  • 一般如果不太关心取值范围的话,直接用int类型就行
  • 如果求严谨就可以使用具体的位数类型,有一些常见的业务场景,我们一般约定
    • 时间戳用int64或者uint64,如果用uint32存时间戳,最大时间为:2106-02-07 14:28:15
    • 统计性质的变量,如果不能为负最好用uint32,一些json库(jsonpb)会把uint64序列化成string,为了避免这种情况最好是用uint32

文章来源:智云一二三科技

文章标题:golang中数字字段的类型约定

文章地址:https://www.zhihuclub.com/109.shtml

关于作者: 智云科技

热门文章

评论已关闭

10条评论

  1. We observed a significant decrease in global YFP NK cell numbers in ILC Eomes О” О” compared to wild type WT control mice in all tissues examined blood, spleen, BM, LN, and liver; Figure 2 A

  2. Before the important studies of Ewing and Klinefelter of 1987 1989 43 45, Leydig cells could be isolated, but when cultured they rapidly lost the capacity to produce LH- stimulated testosterone

  3. Hello i got high blood pressure during pregnancy at 6 months and it was mentained with medication untill i gave birth

  4. He carefully urged the extremely cold Dan Yuan, and then gradually moved it into the Dantian

  5. 3 NeuroMab Cat 73 009, RRID AB_10673575, rabbit anti c fos Cell Signaling Technology Cat 2250, RRID AB_2247211 and rabbit anti ATF3 Santa Cruz Biotechnology Cat sc 188, RRID AB_2258513

网站地图