在專案中使用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()

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/252998.html
標籤:其他
上一篇:樂鑫ESP32完美對標AP6212,國產芯片不缺貨,不漲價!牛
下一篇:spark在風控用戶團伙中的應用
