push
github
5 of 21 new or added lines in 2 files covered. (23.81%)
1806 of 2319 relevant lines covered (77.88%)
3.52 hits per line
1 |
package maputil
|
|
2 |
|
|
3 |
// Data an map data type
|
|
4 |
type Data map[string]interface{} |
|
5 |
|
|
6 |
// Get value from the data map
|
|
NEW
|
func (d Data) Get(key string) interface{} { |
× |
NEW
|
return d[key]
|
× |
NEW
|
} |
× |
10 |
|
|
11 |
// Set value to the data map
|
|
NEW
|
func (d Data) Set(key string, val interface{}) { |
× |
NEW
|
d[key] = val |
× |
NEW
|
} |
× |
15 |
|
|
16 |
// Has value on the data map
|
|
NEW
|
func (d Data) Has(key string) bool { |
× |
NEW
|
_, ok := d[key] |
× |
NEW
|
return ok
|
× |
NEW
|
} |
× |
21 |
|
|
22 |
// Default get value from the data map with default value
|
|
NEW
|
func (d Data) Default(key string, def interface{}) interface{} { |
× |
NEW
|
val, ok := d[key] |
× |
NEW
|
if ok {
|
× |
NEW
|
return val
|
× |
NEW
|
} |
× |
28 |
|
|
NEW
|
return def
|
× |
30 |
} |