# Go: panic: reflect: call of reflect.Value.Elem on zero Value

**Code:** `reflect: call of reflect.Value.X on zero Value` · **Category:** Go · **Seen on:** Go

Reflection code operated on an invalid (zero) `reflect.Value`, often derived from a nil pointer or a missing struct field.

## Meaning

`reflect.ValueOf(nil)` and `FieldByName` for a nonexistent field return an invalid Value. Check `v.IsValid()` and `v.Kind()` before calling methods. JSON/validation libraries trigger this when given nil interfaces.

## Common causes

- reflect.ValueOf(nil)
- FieldByName for a missing field
- Elem() on a nil pointer
- Interface holding nil passed to a library
- Wrong struct tag lookup

## Quick fix

1. Check `v.IsValid()` and `v.Kind() == reflect.Ptr && !v.IsNil()`
2. Pass a non-nil pointer to Unmarshal/Scan
3. Validate field names

## Detailed fix by platform

### Go

1. `if !v.IsValid() { return errors.New("invalid value") }`

## How to diagnose

1. **Value** — IsValid?
2. **Kind** — Pointer nil?
3. **Field** — Exists?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/go/reflect-call-on-zero-value)
