我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

Goroutine不会遍历切片

I have this code:

for _, v := range sams {
    sam := v
    pid := getPracticeIdBySam(db, sam)

    go func() {
        defer wg.Done()

        for _, v := range pid {
            process(db, stmt, v, min_year, max_year, bar)
        }
    }()
}

It iterates through the first "pid", however it stops there. Is there a reason for this?

I found out the reason. It is because I had wg.Wait() in process which in turn caused it to hang.

近期文章

  • 在Go中解析多个XML标签
  • Ansible GVM-Go版本管理器
  • GitHub无法正确解析密钥GoLang API请求
  • Google Cloud SDK无法启动Docker映像Mac OS的预览
  • 我可以直接在没有beego中的路由器的情况下直接从主站调用控制器吗
  • 使用Google Analytics(分析)中的数据按国家/地区返回浏览量最高的项目
  • 如何修复IP地址但由DialTCP内核选择的左端口号?
  • App Engine:将数据加载到自动缩放的实例的内存中
  • kubernetes go客户端用于节点和集群的存储
  • 用空字段解析json [重复]
  • 如何在Go中获取客户端IPv4地址?
  • 编写零垃圾代码
  • 更新某些用户字段
  • golang字符串通道发送/接收不一致
  • Goclipse在Ubuntu上转到二进制位置
  • 源代码结构:部署带有子包的Go
  • Golang OpenGL顶点结构
  • 如何将{name:value}对与Gorilla Mux HandleFunc配合使用?
  • 如何在实时应用程序RethinkDB上访问/安装/设置Web面板
  • 如何在Go中从多个表构造对象

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华