You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
what version are you using? I just added this test for a quick check on latest version and it passes fine
func TestSetArray(t *testing.T) {
data := map[string]interface{}{
"name": "Alice",
"age": 30,
"hobbies": []string{
"reading",
"swimming",
"running",
},
}
d := objx.Map(data)
d = d.Set("hobbies[0]", "coding")
assert.Equal(t, "coding", d.Get("hobbies[0]").String())
}
my version is v0.5.0
in your test case, the type of struct field( "hobbies") has been change to string, you can print the object "d", here is my print result:
this is my code:
func main() {
data := map[string]interface{}{
"name": "Alice",
"age": 30,
"hobbies": []string{
"reading",
"swimming",
"running",
},
}
}
my result is: after set -> map[age:30 hobbies:sssss name:Alice]
what I expect is: after set -> map[age:30 hobbies:[coding, swimming, running] name:Alice]
it seems that there is a bug in obj.Set function when I want to modify a value in the array?
The text was updated successfully, but these errors were encountered: