To test concurrent goroutines, I added a line to a function to make it take a random time to return (up to one second)
time.Sleep(rand.Int31n(1000) * time.Millisecond)
However when I compiled, I got this error
.crawler.go:49: invalid operation: rand.Int31n(1000) * time.Millisecond (mismatched types int32 and time.Duration)
Any ideas? How can I multiply a duration?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…