-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
bugIt is confirmed a bug, but don't worry, we'll handle it.It is confirmed a bug, but don't worry, we'll handle it.
Description
Go version
1.25
GoFrame version
2.9.6
Can this bug be reproduced with the latest release?
Option Yes
What did you do?
func TestGconv(t *testing.T) {
extraStr := `
{
"USD": {
"CNY": 7
}
}`
extra := map[string]any{}
err := json.Unmarshal([]byte(extraStr), &extra)
if err != nil {
t.Fatal(err)
}
fmt.Printf("extra type: %T\n", extra)
fmt.Printf("extra USD type: %T\n", extra["USD"])
fmt.Printf("extra: %v\n", extra)
exchangeRate := make(ExchangeRate)
err = gconv.Scan(extra, &exchangeRate)
if err != nil {
t.Fatal(err)
}
fmt.Printf("exchangeRate type: %T\n", exchangeRate)
fmt.Printf("exchangeRate USD type: %T\n", exchangeRate["USD"])
fmt.Printf("exchangeRate: %v\n", exchangeRate)
}What did you see happen?
=== RUN TestGconv
extra type: map[string]interface {}
extra USD type: map[string]interface {}
extra: map[USD:map[CNY:7]]
exchangeRate type: ExchangeRate
exchangeRate USD type: map[string]float64
exchangeRate: map[USD:map[]]
--- PASS: TestGconv (0.00s)
PASS
exchangeRate.USD.CNY is lose
What did you expect to see?
exchangeRate.USD.CNY = 7
Metadata
Metadata
Assignees
Labels
bugIt is confirmed a bug, but don't worry, we'll handle it.It is confirmed a bug, but don't worry, we'll handle it.