# 恐慌：sync: Mutex 已锁定（复制了 sync.Mutex 的值）

- **ID:** `go/mutex-copy-after-use`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

sync.Mutex 在使用后被复制，导致未定义行为，并因 vet 或运行时检测而恐慌。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.19 | active | — | — |
| 1.21 | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   Always use pointer to the struct that holds the mutex, never copy it. Example: func (m *MyStruct) Lock()
   ```
2. **** (90% 成功率)
   ```
   Use sync.Mutex as a field and embed it in a struct that is always used via pointer.
   ```

## 无效尝试

- **** — Undefined behavior can corrupt data or crash later; not safe. (90% 失败率)
- **** — Copying the struct still copies the mutex; pointer receiver alone doesn't help. (80% 失败率)
