# flag redefined: -name

- **ID:** `go/flag-redefined`
- **Domain:** go
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 87%

## Root Cause

The same flag name is registered twice via the flag package, typically due to importing two packages that define the same flag or calling flag.StringVar with the same name in multiple places.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Go 1.18 | active | — | — |
| Go 1.19 | active | — | — |
| Go 1.20 | active | — | — |

## Workarounds

1. **Define all flags in the main function or a single initialization function, and call flag.Parse() only once** (95% success)
   ```
   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** (90% success)
   ```
   Use flag.NewFlagSet to create separate flag sets for different packages or components
   ```

## Dead Ends

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