wolfogre / blog-utterances

utterances of my blog.
5 stars 0 forks source link

彻底搞懂 golang 里的 iota #40

Open wolfogre opened 5 years ago

wolfogre commented 5 years ago

https://blog.wolfogre.com/posts/golang-iota/

zqb7 commented 5 years ago

优质博客+1

angryLid commented 4 years ago

作者有心了,果断收藏此文

infiniteDemon commented 2 years ago

有心作者+1

Andrewpqc commented 2 years ago

刚被人用这玩意儿侮辱了一番

fatcatmimi commented 11 months ago

好文+1

zzmmff commented 6 months ago

作者后面的 免死声明笑死我了

BY-H commented 5 months ago

好文,感谢博主

shawnfinelee commented 4 months ago

真的会在工程里出现这种代码吗?

quanqigu commented 3 months ago

有被作者声明笑到,今天确实遇到第四个问题。

const (
    QualityOK     int32 = 200
    QualityGood   int32 = 201
    QualityGreat  int32 = 202
    QualityLow       = 400 + iota
    QualityPoor 
)

我期待着QualityPoor应该打印401,然而它打一架的是404。。。所以我真的到你这来了。。。

liuqin19980818 commented 1 month ago

const (
    mutexLocked = 1 << iota
    mutexWoken
    mutexStarving
    mutexWaiterShift = iota
)

1 2 4 3


const (
    mutexLocked = 1 << iota //iota =0
    mutexWoken//iota=1
    mutexStarving//iota=2
    mutexWaiterShift = iota//iota=3
)

const (
    mutexLocked = 1 << 0
    mutexWoken = 1 << 1
    mutexStarving = 1 << 2
    mutexWaiterShift =  3
)

const (
    mutexLocked = 1
    mutexWoken = 2
    mutexStarving = 4
    mutexWaiterShift =  3
)