小编Xue*_* Ye的帖子

在 Go 中修改切片时如何避免竞争条件?

func sample(testList []struct{}, testMap map[int64]struct{}) {
    for i, test := range testList {
        // some if conditions to get the matched key
        testList[i] = testMap[key]
    }
}
Run Code Online (Sandbox Code Playgroud)

map 和 slice 的值是相同的类型。我将使用一些匹配的地图值来替换切片中的值。

dictionary go slice

0
推荐指数
1
解决办法
73
查看次数

标签 统计

dictionary ×1

go ×1

slice ×1