diff --git a/smap/smap.go b/smap/smap.go index 17eaa56..a5d047c 100644 --- a/smap/smap.go +++ b/smap/smap.go @@ -39,12 +39,16 @@ func (l *list) Get(k string) string { return "" } func (l *list) Delete(k string) { + list := []kv{} + for i := 0; i < len(l.list); i++ { - if l.list[i].key == k { - l.list[i].val = "" + if l.list[i].key != k { + list = append(list, l.list[i]) } } + l.list = list } + func (l *list) Len() int { return len(l.list) } diff --git a/smap/smap_test.go b/smap/smap_test.go index 824826f..3565ccc 100644 --- a/smap/smap_test.go +++ b/smap/smap_test.go @@ -33,7 +33,7 @@ func Test_Get(t *testing.T) { func Test_Len(t *testing.T) { if smp.Len() != len(cases) { t.Errorf("have %d, want %d", smp.Len(), len(cases)) - // t.Error(smp.list, cases) + //t.Error(smp.list, cases) } } @@ -64,7 +64,7 @@ func Test_Delete(t *testing.T) { func Test_Len3(t *testing.T) { if smp.Len() >= len(cases) { - //t.Errorf("have %d, want %d", smp.Len(), len(cases)-1) + t.Errorf("have %d, want %d", smp.Len(), len(cases)-1) // t.Error("\n", smp.list, "\n", cases) } }