当前位置:网站首页>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。
边栏推荐
- 并查集模板
- 怎么使用【jmeter正则表达式提取器】解决返回值作参数的问题
- CV+Deep Learning - network architecture Pytorch recurrence series - classification (3: MobileNet, ShuffleNet)
- 高等数学(第七版)同济大学 习题4-3 个人解答
- js reads excel time format conversion
- 组合数模板
- Ask next CDC mysql to Doris. Don't show the specific number of lines, how to do?
- NaiveUI中看起来没啥用的组件(文字渐变)实现原来这么简单
- Synchronization lock synchronized traces the source
- CV-人脸识别-2018:ArcFace
猜你喜欢
【OAuth2】二十、OAuth2扩展协议 PKCE
怎么使用【jmeter正则表达式提取器】解决返回值作参数的问题
Pieces of TensorFlow 2.9 (1)
[OAuth2] 20. OAuth2 Extended Protocol PKCE
VS2013-debug assembly code-generate asm file-structure memory layout-function parameter stack-calling convention
ARM结构体系3:ARM指令的寻址和异常中断处理
高性能短连接设计
Quickly enter the current date and time
mySQL增删改查进阶
数据库注入提权总结(一)
随机推荐
大佬们,请问一下,oraclecdc报错没有序列化,可是我看源码中的确是没有继承序列化的,是什么原因
1-31部 1-31套 和硬件工程师90天学习资料及笔记汇总
PTA 习题2.2 数组循环左移
js reads excel time format conversion
Uni-app开发微信小程序使用本地图片做背景图
FFT模板
Pieces of TensorFlow 2.9 (1)
【微信小程序】一文读懂页面导航
Rust learning: 6.3_ Tuples of composite types
【FAQ】【Push Kit】推送服务,回执配置一直报错、回执过期修改、怎么删除配置的回执
DAY25: Logic vulnerability recurrence
人
短视频同城流量宣传小魔推有何优势?如何给实体商家带来销量?
解决win10win7win8系统找不到指定的模块,注册不了大漠插件的问题
PTA Exercise 2.2 Rotate an Array Left
VS2013-debug assembly code-generate asm file-structure memory layout-function parameter stack-calling convention
UGUI - Events, iTween Plugin
How AliExpress sellers seize product search weight
ShardingSphere入门
ARM Architecture 3: Addressing and Exception Handling of ARM Instructions