# go: 不一致的构建约束: //go:build linux && !linux

- **ID:** `go/build-constraint-conflict`
- **领域:** go
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

文件包含矛盾的构建标签，无法同时为真，导致文件被忽略或构建错误。

## 版本兼容性

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

## 解决方案

1. **Correct the build constraint to be logically consistent.** (95% 成功率)
   ```
   Change '//go:build linux && !linux' to a valid constraint like '//go:build linux'.
   ```
2. **Use separate files for different platforms with proper build tags.** (90% 成功率)
   ```
   Create platform-specific files (e.g., file_linux.go, file_windows.go) with correct tags.
   ```

## 无效尝试

- **Removing all build constraints from the file.** — The file will be built for all platforms, which may cause compilation errors on unsupported OS. (60% 失败率)
- **Adding more build constraints to override.** — More constraints can create further conflicts; the logic must be consistent. (80% 失败率)
