patch time: Duration, Timer

This commit is contained in:
xushiwei
2024-07-09 14:24:48 +08:00
parent b64775772b
commit 06bd748bd6
5 changed files with 716 additions and 18 deletions

19
_demo/_timeout/timer.go Normal file
View File

@@ -0,0 +1,19 @@
package main
import (
"fmt"
"time"
)
var c chan int
func handle(int) {}
func main() {
select {
case m := <-c:
handle(m)
case <-time.After(10 * time.Second):
fmt.Println("timed out")
}
}