I am trying to calculate a time to sleep but am stuck. I can sleep for 10 seconds:
time.Sleep(10 * time.Second)
However, I try the following:
package main
import (
"log"
"time"
"reflect"
)
func main() {
n := time.Now()
remaining := 10 - int(time.Since(n).Seconds())
log.Println(reflect.TypeOf(10), reflect.TypeOf(remaining))
//time.Sleep(10 * time.Second)
time.Sleep(remaining * time.Second)
}
I get:
invalid operation: remaining * time.Second (mismatched types int and time.Duration)
remaining is an int, just as 10 is an int. What gives?