mirror of
https://github.com/teivah/100-go-mistakes.git
synced 2026-06-21 17:07:18 +08:00
31 lines
335 B
Go
31 lines
335 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
listing1()
|
|
//listing2()
|
|
}
|
|
|
|
func listing1() {
|
|
ticker := time.NewTicker(1000)
|
|
for {
|
|
select {
|
|
case <-ticker.C:
|
|
fmt.Println("tick")
|
|
}
|
|
}
|
|
}
|
|
|
|
func listing2() {
|
|
ticker := time.NewTicker(time.Microsecond)
|
|
for {
|
|
select {
|
|
case <-ticker.C:
|
|
fmt.Println("tick")
|
|
}
|
|
}
|
|
}
|