-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Problem:
The code encounters an unknown path: Shelf.Orange.Qty error. This happens because the dot package might not be designed to handle nested maps where keys are object
package main
import (
"fmt"
"github.com/mowshon/dot"
)
type MyShopStock struct {
Shelf map[string]any
Werehouse map[string]any
}
type Product struct {
Price float64
Name string
Qty uint
}
type Inventory struct {
Name string
Qty uint
}
func main() {
data := &MyShopStock{
Shelf: map[string]any{
"Apple": Product{Price: 1.99, Name: "apple", Qty: 10},
"Banana": Product{Price: 0.99, Name: "banana", Qty: 5},
"Orange": Product{},
},
}
obj, err := dot.New(data)
if err != nil {
panic(err)
}
err = obj.Insert("Shelf.Orange.Qty", 5)
if err != nil {
panic(err)
}
fmt.Println(data.Shelf["Orange"])
}https://go.dev/play/p/wBnrgKh67VU
Expected Behavior:
The Insert operation should successfully set the Qty for "Orange" to 5 without errors.
Observations:
It seems the dot package might not be handling nested maps as expected.
mowshon
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working