config/reader.Values add Set for specific path merge (#1099)

* add Set for specific path merge

* add Set

* add Del
This commit is contained in:
Shu xian 2020-01-12 04:50:09 +08:00 committed by Asim Aslam
parent f50a50eeb3
commit fa5b3ee9d9
2 changed files with 24 additions and 0 deletions

View File

@ -172,6 +172,28 @@ func (c *config) Get(path ...string) reader.Value {
return newValue() return newValue()
} }
func (c *config) Set(val interface{}, path ...string) {
c.Lock()
defer c.Unlock()
if c.vals != nil {
c.vals.Set(val, path...)
}
return
}
func (c *config) Del(path ...string) {
c.Lock()
defer c.Unlock()
if c.vals != nil {
c.vals.Del(path...)
}
return
}
func (c *config) Bytes() []byte { func (c *config) Bytes() []byte {
c.RLock() c.RLock()
defer c.RUnlock() defer c.RUnlock()

View File

@ -18,6 +18,8 @@ type Reader interface {
type Values interface { type Values interface {
Bytes() []byte Bytes() []byte
Get(path ...string) Value Get(path ...string) Value
Set(val interface{}, path ...string)
Del(path ...string)
Map() map[string]interface{} Map() map[string]interface{}
Scan(v interface{}) error Scan(v interface{}) error
} }