# Go: assignment mismatch: 1 variable but os.Open returns 2 values

**Code:** `assignment mismatch: 1 variable but f returns 2 values` · **Category:** Go · **Seen on:** Go

The number of variables on the left does not match the number of values the function returns.

## Meaning

Go functions often return `(value, error)`. Capture both (`f, err := os.Open(p)`) or discard with `_`. The same error appears when a function returns nothing but you assign its result.

## Common causes

- Ignoring the error return
- Function changed to return an extra value
- Using the result of a function that returns nothing
- Wrong number in `return` statement
- Range over map with one variable of wrong kind

## Quick fix

1. `f, err := os.Open(p); if err != nil { … }`
2. Use `_` for values you don't need
3. Update callers after signature changes

## Detailed fix by platform

### Go

1. Never ignore errors silently; run `go vet` and `errcheck` to find them

## How to diagnose

1. **Returns** — How many values?
2. **Left** — Variables count?
3. **Error** — Handled?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/go/assignment-mismatch)
