如下代码,死循环的go程怎么退出呢?
```
package main
import (
"fmt"
"github.com/garyburd/redigo/redis"
)
func subscribe() int {
c, _ := redis.Dial("tcp", "127.0.0.1:6379")
psc := redis.PubSubConn{c}
psc.Subscribe("subs_key")
for {
switch v := psc.Receive().(type) {
case redis.Message:
fmt.Printf("chan %v, data=%v\n", v.Channel, v.Data)
case redis.Subscription:
case error:
}
}
}
func main() {
go subscribe()
}
```
有疑问加站长微信联系(非本文作者)