> For the complete documentation index, see [llms.txt](https://easonwang.gitbook.io/golang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://easonwang.gitbook.io/golang/ji-ben-yu-fa/channel/for-select-yu-for-range.md).

# for select 與 for range

可以使用下面兩方法持續監聽 channel

for select

```go
package main
import (
    "fmt"
    "time"
)

func main() {
    ticker := time.NewTicker(1 * time.Second)
	for {
	  select {
	    case <-ticker.C:
		  fmt.Println("test")  
	  }
	}
}
```

for range

```go
package main
import (
    "fmt"
    "time"
)

func main() {
    ticker := time.NewTicker(1 * time.Second)
    for range ticker.C {
      fmt.Println("test")  
    }
}
```
