# flag: -flag needs an argument: -value

- **ID:** `go/flag-parse-unexpected-value`
- **Domain:** go
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 88%

## Root Cause

A boolean flag or a flag expecting a value is followed by another flag without a value separator, causing the next flag to be interpreted as the value.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| go1.21 | active | — | — |
| go1.22 | active | — | — |
| go1.23 | active | — | — |

## Workarounds

1. **Provide the value after a space: -flag value, or use =: -flag=value. Ensure the flag type matches (e.g., int, string).** (95% success)
   ```
   Provide the value after a space: -flag value, or use =: -flag=value. Ensure the flag type matches (e.g., int, string).
   ```
2. **If the flag is meant to be boolean, define it as bool and don't pass a value: flag.Bool("flag", false, "usage")** (90% success)
   ```
   If the flag is meant to be boolean, define it as bool and don't pass a value: flag.Bool("flag", false, "usage")
   ```

## Dead Ends

- **Adding = between flag and value: -flag=value** — This works for flags expecting values, but if the flag is defined as bool, it still fails because bool flags don't take values. (40% fail)
- **Using double dashes --flag value** — Go's flag package treats -- as prefix for long flags; it doesn't change the parsing behavior for value requirement. (60% fail)
