# Go: panic: interface conversion: interface {} is string, not int

**Code:** `panic: interface conversion` · **Category:** Go · **Seen on:** Go

A type assertion `x.(T)` failed because the dynamic type of the interface is not T.

## Meaning

Use the two-value form `v, ok := x.(T)` to check safely, or a type switch. `interface conversion: interface is nil, not X` means the interface holds nil. JSON decoding into `interface{}` yields `float64` for numbers, not `int`.

## Common causes

- Asserting without the ok form
- JSON numbers decoded as float64
- Nil interface value
- Wrong type stored in map[string]interface{}
- Pointer vs value type mismatch

## Quick fix

1. `v, ok := x.(int); if !ok { … }`
2. Use a type switch for several types
3. Decode JSON into typed structs instead of interface{}

## Detailed fix by platform

### Go

1. `switch t := x.(type) { case int: … case float64: … case string: … default: … }`

## How to diagnose

1. **Dynamic type** — Actual vs expected?
2. **Form** — ok-check used?
3. **JSON** — float64?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/go/interface-conversion-panic)
