gitee.com/sy_183/go-common@v1.0.5-0.20231205030221-958cfe129b47/timer/timer_test.go (about) 1 package timer 2 3 import ( 4 "testing" 5 "time" 6 ) 7 8 func TestTimer(t *testing.T) { 9 timer := time.AfterFunc(time.Second, func() { 10 println("timeout") 11 }) 12 13 time.Sleep(time.Second * 2) 14 15 if stopped := timer.Stop(); stopped { 16 println(stopped) 17 } 18 }