various time
This commit is contained in:
parent
1a21dcacfa
commit
e1a8b31f00
13
README
13
README
@ -33,18 +33,8 @@ gobyexample.com signups
|
|||||||
* updates forever
|
* updates forever
|
||||||
* no drm
|
* no drm
|
||||||
|
|
||||||
= source
|
|
||||||
* popular github libraries
|
|
||||||
* mailing list questions
|
|
||||||
* stack overflow questions
|
|
||||||
* handbook format
|
|
||||||
* rosetta stone
|
|
||||||
* building an actual fucking app
|
|
||||||
* ruby and nodejs stdlib
|
|
||||||
* ruby and nodejs killer apps
|
|
||||||
|
|
||||||
= topics
|
= topics
|
||||||
* time
|
* time formatting
|
||||||
* connection pool
|
* connection pool
|
||||||
* typed json parse/unparse
|
* typed json parse/unparse
|
||||||
* web app
|
* web app
|
||||||
@ -62,7 +52,6 @@ gobyexample.com signups
|
|||||||
* hipache port
|
* hipache port
|
||||||
* ssh
|
* ssh
|
||||||
* dns
|
* dns
|
||||||
* timers
|
|
||||||
* tty
|
* tty
|
||||||
* iota
|
* iota
|
||||||
* oauth for google domains
|
* oauth for google domains
|
||||||
|
15
src/xx-tickers.go
Normal file
15
src/xx-tickers.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import ("time"; "fmt")
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
ticker := time.NewTicker(time.Millisecond * 500)
|
||||||
|
go func() {
|
||||||
|
for t := range ticker.C {
|
||||||
|
fmt.Println("Tick at", t)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
time.Sleep(time.Millisecond * 3000)
|
||||||
|
ticker.Stop()
|
||||||
|
fmt.Println("Ticker stopped")
|
||||||
|
}
|
18
src/xx-time.go
Normal file
18
src/xx-time.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import ("time"; "fmt")
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
now := time.Now()
|
||||||
|
fmt.Println(now)
|
||||||
|
|
||||||
|
then := time.Date(2009, 11, 17, 20, 34, 58, 651387237, time.UTC)
|
||||||
|
fmt.Println(then)
|
||||||
|
|
||||||
|
diff := now.Sub(then)
|
||||||
|
fmt.Println(diff)
|
||||||
|
|
||||||
|
// extract parts
|
||||||
|
// add duration
|
||||||
|
// check before / after
|
||||||
|
}
|
20
src/xx-timers.go
Normal file
20
src/xx-timers.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import ("time"; "fmt")
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
timer1 := time.NewTimer(time.Millisecond * 500)
|
||||||
|
<- timer1.C
|
||||||
|
fmt.Println("Timer 1 expired")
|
||||||
|
stopped1 := timer1.Stop()
|
||||||
|
fmt.Println("Timer 2 stopped:", stopped1)
|
||||||
|
|
||||||
|
timer2 := time.NewTimer(time.Second)
|
||||||
|
go func() {
|
||||||
|
<- timer2.C
|
||||||
|
fmt.Println("Timer 2 expired")
|
||||||
|
}()
|
||||||
|
time.Sleep(time.Millisecond * 500)
|
||||||
|
stopped2 := timer2.Stop()
|
||||||
|
fmt.Println("Timer 2 stopped:", stopped2)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user