remove number for source
This commit is contained in:
24
src/timers/timers.go
Normal file
24
src/timers/timers.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// ## Timers
|
||||
|
||||
package main
|
||||
|
||||
import "time"
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
timer1 := time.NewTimer(time.Second)
|
||||
<-timer1.C
|
||||
fmt.Println("Timer 1 expired")
|
||||
stop1 := timer1.Stop()
|
||||
fmt.Println("Timer 2 stopped:", stop1)
|
||||
|
||||
timer2 := time.NewTimer(time.Second)
|
||||
go func() {
|
||||
<-timer2.C
|
||||
fmt.Println("Timer 2 expired")
|
||||
}()
|
||||
stop2 := timer2.Stop()
|
||||
fmt.Println("Timer 2 stopped:", stop2)
|
||||
}
|
||||
|
||||
// todo: pull from blog post
|
||||
4
src/timers/tiners.sh
Normal file
4
src/timers/tiners.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
$ go run timers.go
|
||||
Timer 1 expired
|
||||
Timer 2 stopped: false
|
||||
Timer 2 stopped: true
|
||||
Reference in New Issue
Block a user