Match the types of argument to time.Sleep
:
r := rand.Intn(10)
time.Sleep(time.Duration(r) * time.Microsecond)
This works because time.Duration
has int64
as its underlying type:
type Duration int64
Docs: https://golang.org/pkg/time/#Duration