# 缺陷: select 随机选择 case，观察到消息乱序

- **ID:** `go/select-random-case-when-multiple-ready`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

当多个 select case 同时就绪时，Go 伪随机选择一个。假设确定性顺序或优先级的代码会出错。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.x | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   select {
case v := <-highPriority:
    handle(v)
default:
    select {
    case v := <-highPriority:
        handle(v)
    case v := <-lowPriority:
        handle(v)
    }
}
   ```
2. **** (85% 成功率)
   ```
   type msg struct { prio int; body any }
// single channel; consumer sorts or dispatches by prio
   ```

## 无效尝试

- **** — Go does not honor case order for priority; selection is random. (95% 失败率)
- **** — Doesn't affect select semantics and adds latency. (90% 失败率)
