# 标志重复定义：-name

- **ID:** `go/flag-redefined`
- **领域:** go
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 87%

## 根因

通过flag包注册了相同的标志名称，通常是由于导入了两个定义相同标志的包，或在多个地方使用相同的名称调用flag.StringVar。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Go 1.18 | active | — | — |
| Go 1.19 | active | — | — |
| Go 1.20 | active | — | — |

## 解决方案

1. ```
   Define all flags in the main function or a single initialization function, and call flag.Parse() only once
   ```
2. ```
   Use flag.NewFlagSet to create separate flag sets for different packages or components
   ```

## 无效尝试

- **** — This may break command-line interface consistency or cause confusion if the flag has a standard meaning. (50% 失败率)
- **** — The underlying cause (duplicate registration) still exists; pflag may also panic on duplicate definitions. (70% 失败率)
