I'm trying to write my own sleep function equivalent to time.Sleep
using time.After
in Go.
Here's the code. First attempt:
func Sleep(x int) {
msg := make(chan int)
msg := <- time.After(time.Second * x)
}
Second attempt:
func Sleep(x int) {
time.After(time.Second * x)
}
Both return errors, can someone explain to me how to write a sleep function equivalent to time.Sleep
using time.After
and if possible when do I use channel?