How to use sleep in Go

1 Answer

0 votes
package main

import (
	"fmt"
	"time"
)

func main() {
	start := time.Now()

	time.Sleep(1 * time.Second)

	fmt.Println("Sleep time in ms =", time.Since(start).Milliseconds())
}



/*
run:

Sleep time in ms = 1000

*/

 



answered Sep 1, 2024 by avibootz
...