valuer.go 512 B

123456789101112131415161718
  1. package mapping
  2. type (
  3. // A Valuer interface defines the way to get values from the underlying object with keys.
  4. Valuer interface {
  5. // Value gets the value associated with the given key.
  6. Value(key string) (interface{}, bool)
  7. }
  8. // A MapValuer is a map that can use Value method to get values with given keys.
  9. MapValuer map[string]interface{}
  10. )
  11. // Value gets the value associated with the given key from mv.
  12. func (mv MapValuer) Value(key string) (interface{}, bool) {
  13. v, ok := mv[key]
  14. return v, ok
  15. }