golang 使用time包碰到数字与时间相乘的问题

   日期:2021-01-27     浏览:152    评论:0    
核心提示:在项目中使用time包时,睡眠时间时想要通过配置文件获取,然而整数与时间相乘又报错。如下查询time包发现// A Duration represents the elapsed time between two instants// as an int64 nanosecond count. The representation limits the// largest representable duration to approximately 290 years.t...

       在项目中使用time包时,睡眠时间时想要通过配置文件获取,然而整数与时间相乘又报错。如下

查询time包发现

// A Duration represents the elapsed time between two instants
// as an int64 nanosecond count. The representation limits the
// largest representable duration to approximately 290 years.
type Duration int64

即,其实就是一个int64的数。最后先把需要的数字进行转换,这样解决即可

err = client.Set(ctx, key, data, time.Duration(ex)*time.Second).Err()

 
打赏
 本文转载自:网络 
所有权利归属于原作者,如文章来源标示错误或侵犯了您的权利请联系微信13520258486
更多>最近资讯中心
更多>最新资讯中心
0相关评论

推荐图文
推荐资讯中心
点击排行
最新信息
新手指南
采购商服务
供应商服务
交易安全
关注我们
手机网站:
新浪微博:
微信关注:

13520258486

周一至周五 9:00-18:00
(其他时间联系在线客服)

24小时在线客服