zl程序教程

您现在的位置是:首页 >  后端

当前栏目

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

Go输出语言代码 什么 2022 13 24
2023-06-13 09:14:40 时间

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。什么原因,不清楚,网上也没找到原因。