If I want to sleep for 2 seconds I can do the following:
time.Sleep(2 * time.Second)
but when I do:
test := 2
time.Sleep(test * time.Second)
It throws the error
invalid operation: test * time.Second (mismatched types int and time.Duration)
I can fix this by casting test
like so: time.Sleep(time.Duration(rand.Intn(5)) * time.Second)
but i'm wondering why it is that I need to wrap it in time.Duration
when it's a variable and not when it's a raw value?