2022-09-24:以下go语言代码输出什么?A:1;B:3;C:13;D:7。 package main import ( “fmt“ “io/ioutil“ “net/

2022-09-24:以下go语言代码输出什么?A:1;B:3;C:13;D:7。

package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"runtime"
)

func main() {
	num := 6
	for index := 0; index < num; index++ {
		resp, _ := http.Get("https://www.baidu.com")
		_, _ = ioutil.ReadAll(resp.Body)
	}
	fmt.Printf("此时goroutine个数= %d\n", runtime.NumGoroutine())
}

答案选B。什么原因,不清楚,网上也没找到原因。
在这里插入图片描述

posted @ 2022-09-24 22:54  福大大架构师每日一题  阅读(34)  评论(0)    收藏  举报  来源