加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

golang 声明常量

发布时间:2020-12-16 18:43:04 所属栏目:大数据 来源:网络整理
导读:*声明一个常量 constMAX=4096 *声明一个指定类型的常量 constLIMITint16=1024constLIMIT2=int16(1024) *声明一组常量 const(start=0x1resume=0x2stop=0x4) *声明一组指定类型的常量 const(startint8=0x1resumeint8=0x2stopint8=0x4) *用iota简化上面的

*声明一个常量

constMAX=4096

*声明一个指定类型的常量

constLIMITint16=1024
constLIMIT2=int16(1024)

*声明一组常量

const(
start=0x1
resume=0x2
stop=0x4
)

*声明一组指定类型的常量

const(
startint8=0x1
resumeint8=0x2
stopint8=0x4
)

*用iota简化上面的写法

const(
startint8=1<<iota
resume
stop
)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读