This is a creation in Article, where the information may have evolved or changed.
On the example
Package Mainimport ( // "bytes" // "Encoding/json" "FMT" // "OS"/ / "Gopkg.in/mgo.v2" // "Gopkg.in/mgo.v2/bson" // "Io/ioutil" // "Net/http" // "strings" // "Net/url" "Time") func main () { Ticker:= time. Newticker (Ten * time . Second) for i:= 0; I < 10; i++ {Time := <-Ticker. C FMT. Println (time. String ()) }}
Execution results
Wifimac:webdemo cdpmac$ Go Run src/server/timetest.go
2015-08-24 16:22:23.590564088 +0800 CST
2015-08-24 16:22:33.591194618 +0800 CST
2015-08-24 16:22:43.587720967 +0800 CST
2015-08-24 16:22:53.590231413 +0800 CST
2015-08-24 16:23:03.591164202 +0800 CST
....
You don't have to look down.
I really hate it. Go compile run-time dependency check! There are introduced, but not applied packages that have been created, but not used by the variable, not allowed.
Another special case was found.
Output time, completely out of common sense,
Fmt. Println in theory is output by line, in this case
Actually, it turns out that
2015-08-24 16:22:23.590564088 +0800 cst2015-08-24 16:22:33.591194618 +0800 cst2015-08-24 16:22:43.587720967 +0800 cst2015-08-24 16:22:53.590231413 +0800 cst2015-08-24 16:23:03.591164202 +0800 cst2015-08-24 16:23:13.588811769 +0800 cst2015-08-24 16:23:23.587282627 +0800 cst2015-08-24 16:23:33.588753016 +0800 cst2015-08-24 16:23:43.591157197 +0800 cst2015-08-24 16:23:53.589934072 +0800 CST
It's supposed to be a shell problem.
Continue theme
No ready-made data found.
See the sample test code for the official package
See the time part of Go source code ticker structure
<-chan Time//The channel on which the ticks is DELIVERED.R Runtimetimer}
Time is similar
There is a read-only Chanel "object"
Time and ticket calls to go
or Timmer internal and other language development ideas are completely different.
Other languages, many are registered callback functions, timing, time to call callback.
Go is through Chan
of blocking implementations.
Call the place and read Chan
Timed, time to, write value to Chan, block out, call function.