go-zero/core/mapping/valuer.go

19 lines
512 B
Go
Raw Normal View History

2020-07-26 17:09:05 +08:00
package mapping
type (
// A Valuer interface defines the way to get values from the underlying object with keys.
2020-07-26 17:09:05 +08:00
Valuer interface {
// Value gets the value associated with the given key.
2020-07-26 17:09:05 +08:00
Value(key string) (interface{}, bool)
}
// A MapValuer is a map that can use Value method to get values with given keys.
2020-07-26 17:09:05 +08:00
MapValuer map[string]interface{}
)
// Value gets the value associated with the given key from mv.
2020-07-26 17:09:05 +08:00
func (mv MapValuer) Value(key string) (interface{}, bool) {
v, ok := mv[key]
return v, ok
}