mirror of
https://github.com/astaxie/beego.git
synced 2024-11-21 16:20:53 +00:00
rm some methods
This commit is contained in:
parent
f8c0e6fec5
commit
ce698aacf6
@ -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{
|
||||
|
@ -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)
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user