I'm trying to realize a random sleep dream (in the Golang)
r := rand.Intn(10) time.Sleep(100 * time.Millisecond) //working time.Sleep(r * time.Microsecond) // Not working (mismatched types int and time.Duration)
Match argument types to time.Sleep:
time.Sleep
time.Sleep(time.Duration(r) * time.Microsecond)
This works because it time.Durationhas uint64as its base type:
time.Duration
uint64
type Duration int64
Docs: https://golang.org/pkg/time/#Duration
Source: https://habr.com/ru/post/1679202/More articles:Change platform on Elastic Beanstalk from PHP to Node.js - amazon-web-servicesCannot resolve bean driverClassName - javaThe triple (conditional) expression has the wrong type - cTensorflow.contrib.learn.ExportStrategy example - pythonHow to expand and collapse ListView in Xamarin formats - xamarin.formsUsing SelectIndex proprety Pivot in UWP - c #How to deploy Xamarin Forms app on iOS device for testing - xamarin.formsMKMapView memory leak in iOS 10 - ios10Xamarin Forms IOS "Enter" unedited - androidкак мне преобразовать дату типа "YYYY/MM" в "MMM-YYYY" в pandas в python - pythonAll Articles