```
package main
import "time"
import "fmt"
func a() {
c1 := make(chan string, 1)
go func() {
time.Sleep(time.Second * 2)
c1 <- "result 1"
}()
select {
case res := <-c1:
fmt.Println(res)
case <-time.After(time.Second * 1):
//超时的话如何结束当前的并发进程,并且重新运行a函数
runtime.Goexit()
fmt.Println("timeout 1")
}
}
func b() {
c1 := make(chan string, 1)
go func() {
time.Sleep(time.Second * 2)
c1 <- "result 1"
}()
select {
case res := <-c1:
fmt.Println(res)
case <-time.After(time.Second * 1):
//超时的话如何结束当前的并发进程,并且重新运行a函数
runtime.Goexit()
fmt.Println("timeout 1")
}
}
func main() {
go a()
b()
}
// todo: cancellation?
```
运行结果:提示出错
```
./main.go:23: undefined: runtime in runtime.Goexit
./main.go:40: undefined: runtime in runtime.Goexit
```