From ce698aacf6a5b7d2ebe3ccc25204b65cc0fdeeb3 Mon Sep 17 00:00:00 2001 From: jianzhiyao Date: Tue, 11 Aug 2020 12:06:02 +0800 Subject: [PATCH] rm some methods --- pkg/common/kv.go | 19 ------------------- pkg/common/kv_test.go | 10 ++++------ 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/pkg/common/kv.go b/pkg/common/kv.go index 26e786f9..80797aa9 100644 --- a/pkg/common/kv.go +++ b/pkg/common/kv.go @@ -41,8 +41,6 @@ type KVs interface { GetValueOr(key interface{}, defValue interface{}) interface{} Contains(key interface{}) bool IfContains(key interface{}, action func(value interface{})) KVs - Put(key interface{}, value interface{}) KVs - Clone() KVs } // SimpleKVs will store SimpleKV collection as map @@ -77,23 +75,6 @@ func (kvs *SimpleKVs) IfContains(key interface{}, action func(value interface{}) return kvs } -// Put stores the value -func (kvs *SimpleKVs) Put(key interface{}, value interface{}) KVs { - kvs.kvs[key] = value - return kvs -} - -// Clone -func (kvs *SimpleKVs) Clone() KVs { - newKVs := new(SimpleKVs) - - for key, value := range kvs.kvs { - newKVs.Put(key, value) - } - - return newKVs -} - // NewKVs creates the *KVs instance func NewKVs(kvs ...KV) KVs { res := &SimpleKVs{ diff --git a/pkg/common/kv_test.go b/pkg/common/kv_test.go index 275c6753..7b52a300 100644 --- a/pkg/common/kv_test.go +++ b/pkg/common/kv_test.go @@ -29,12 +29,10 @@ func TestKVs(t *testing.T) { assert.True(t, kvs.Contains(key)) - kvs.IfContains(key, func(value interface{}) { - kvs.Put("my-key1", "") - }) - - assert.True(t, kvs.Contains("my-key1")) - v := kvs.GetValueOr(key, 13) assert.Equal(t, 12, v) + + v = kvs.GetValueOr(`key-not-exists`, 8546) + assert.Equal(t, 8546, v) + }