当前位置:网站首页>2022-08-09:以下go语言代码输出什么?A:否,会 panic;B:是,能正确运行;C:不清楚,看投票结果。
2022-08-09:以下go语言代码输出什么?A:否,会 panic;B:是,能正确运行;C:不清楚,看投票结果。
2022-08-10 08:38:00 【福大大架构师每日一题】
2022-08-09:以下go语言代码输出什么?A:否,会 panic;B:是,能正确运行;C:不清楚,看投票结果。
package main
import (
"fmt"
"sync"
)
func main() {
wg := sync.WaitGroup{}
wg.Add(1)
go hello(wg)
wg.Wait()
}
func hello(wg sync.WaitGroup) {
fmt.Println("hello")
wg.Done()
}答案2022-08-09:
答案选A,因为 hello 的参数是 sync.WaitGroup,这会导致 main 中 wg 被复制一份,起不到该有的作用,应该改为 *sync.WaitGroup。
边栏推荐
猜你喜欢

【Unity入门计划】制作RubyAdventure03-使用碰撞体&触发器实现世界交互

I don't want to do accounting anymore, Die changed to a new one, moved forward bravely, and finally successfully passed the career change test to double his monthly salary~

mySQL add, delete, modify and check advanced

【微信小程序】一文读懂页面导航

解决win10win7win8系统找不到指定的模块,注册不了大漠插件的问题

PTA Exercise 2.2 Rotate an Array Left

【搜索引擎】Solr:提高批量索引的性能

iwemeta元宇宙:阿里首任COO:如何打造销售铁军

ARM结构体系3:ARM指令的寻址和异常中断处理

MySQL的用户临时表与内部临时表
随机推荐
Rust learning: 6.5_Array of composite types
人
The implementation of the seemingly useless component (text gradient) in NaiveUI is so simple
【NeRF】原始论文解读
明明加了唯一索引,为什么还是产生重复数据?
速卖通卖家如何抓住产品搜索权重
CV+Deep Learning——网络架构Pytorch复现系列——classification(三:MobileNet,ShuffleNet)
Rust学习:6.4_复合类型之枚举
Go-Excelize API源码阅读(十一)—— GetActiveSheetIndex()
J9数字科普:Web 3.0 是关于数据所有权还是去中心化?
【Unity入门计划】制作RubyAdventure03-使用碰撞体&触发器实现世界交互
基于sklearn的决策树应用实战
ARM Architecture 2: Processor Core and Assembly Instruction Set
Obtain - 65 [chances] : "soldiers, subtlety also - 7-36 meter reading - defeat
高等数学(第七版)同济大学 习题4-3 个人解答
PTA 习题2.2 数组循环左移
placeholder 1
dayjs-----时间格式化
Go-Excelize API source code reading (11) - GetActiveSheetIndex()
iwemeta元宇宙:一个娃娃卖9999元,泡泡玛特认为一点也不贵