time.Millisecond * int confusion

前端 未结 5 522
臣服心动
臣服心动 2020-12-18 20:12

In the below example, if the 1000\'s are both int\'s (which I think they are) why would the bottom fail to compile?

//works
time.Sleep(1000 * time.Millisecon         


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-18 21:11

    Both operants need to be of the same type time.Duration. You can use time.Sleep(v * time.Millisecond).

提交回复
热议问题