通过此值传递锁定 (append *sync.Mutex 问题)
日常搬砖碰到个warning,复现是这样
type aslice struct {
sync.Mutex
Value string
}
type ademo struct {
slices []aslice
}
func (ademo *ademo) append(aslice aslice) {
ademo.slices = append(ademo.slices, aslice) <-- 就这里
}
GoLand提示告警内容是append 通过此值传递值锁定
疑问来了,有啥影响?
自己能想到的比如 如果aslice在其他地方如果调用过.Lock()
那这个锁定状态也会带在aslice
中一并append过去吗?
这个报错可忽略吗(GoLand警告,编译正常)
那有什么办法才能忽略这个警告呢?
存在锁拷贝,