Skip to content
Snippets Groups Projects
Commit 978a2c9d authored by ensiouel's avatar ensiouel
Browse files

feature: в пакет data добавлена проверка при установке значения на то, инициализирована ли map

parent 250b7e3f
No related branches found
No related tags found
No related merge requests found
......@@ -177,6 +177,10 @@ func set(path []string, data, value any) error {
switch v := data.(type) {
case map[string]interface{}:
if v == nil {
return nil
}
if len(path) == 1 {
if _, ok := value.(DeleteValueType); ok {
......
......@@ -8,6 +8,8 @@ import (
)
func TestDelete(t *testing.T) {
var uninitializedMap map[string]any
tests := []struct {
name string
in interface{}
......@@ -62,6 +64,12 @@ func TestDelete(t *testing.T) {
},
}, "z": "2"},
},
{
"object field from uninitialized map",
uninitializedMap,
"a.b",
uninitializedMap,
},
// Решили что автоматически удалять пустые объекты/слайсы не нужно
//{
// "empty object",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment