您的位置 首页 golang

golang面试题7之下面的代码会报异常吗?

 package main

import (
" runtime "
"fmt"
)

func main() {
runtime.GOMAXPROCS(1)
int_chan := make(chan int, 1)
str_chan := make(chan string, 1)

int_chan <- 1
str_chan <- "hello"

select {
case value := <- int_chan:
fmt.Println("---> " , value)
case value := <- str_chan:
panic(value)
}
}  

其实,是在考察go语言中select中case的特性

文章来源:智云一二三科技

文章标题:golang面试题7之下面的代码会报异常吗?

文章地址:https://www.zhihuclub.com/100435.shtml

关于作者: 智云科技

热门文章

网站地图