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.
Problem:
The code encounters an
unknown path: Shelf.Orange.Qtyerror. This happens because thedotpackage might not be designed to handle nested maps where keys are objecthttps://go.dev/play/p/wBnrgKh67VU
Expected Behavior:
The
Insertoperation should successfully set theQtyfor "Orange" to 5 without errors.Observations:
It seems the
dotpackage might not be handling nested maps as expected.