I've been seeing and developing an improvement so that the GetByPath
function supports access to slice structures.
I added the following tests in TestGetByPath
and they pass successfully.
//...
v, ok = maputil.GetByPath("key2", mp)
assert.True(t, ok)
assert.Equal(t, mp["key2"], v)
v, ok = maputil.GetByPath("key2.0", mp)
assert.True(t, ok)
assert.Equal(t, "sv1", v)
v, ok = maputil.GetByPath("key2.1", mp)
assert.True(t, ok)
assert.Equal(t, "sv2", v)
v, ok = maputil.GetByPath("key4.0", mp)
assert.True(t, ok)
assert.Equal(t, 1, v)
v, ok = maputil.GetByPath("key4.1", mp)
assert.True(t, ok)
assert.Equal(t, 2, v)
v, ok = maputil.GetByPath("key5.0", mp)
assert.True(t, ok)
assert.Equal(t, 1, v)
v, ok = maputil.GetByPath("key5.1", mp)
assert.True(t, ok)
assert.Equal(t, "2", v)
v, ok = maputil.GetByPath("key5.2", mp)
assert.True(t, ok)
assert.Equal(t, true, v)
// Out of bound value
v, ok = maputil.GetByPath("key2.2", mp)
assert.False(t, ok)
assert.Nil(t, v)
//...
Owner Name | gookit |
Repo Name | goutil |
Full Name | gookit/goutil |
Language | Go |
Created Date | 2018-07-03 |
Updated Date | 2023-03-22 |
Star Count | 1263 |
Watcher Count | 29 |
Fork Count | 142 |
Issue Count | 3 |