code: func marshalMap(x interface{}) (map[string]interface{}, error) {
  	val := reflect.ValueOf(x)
  	if val.Kind() != reflect.Ptr {
  		return nil, errors.Errorf("expected a pointer to a struct, got %v", val.Kind())
  	}
  	if val.IsNil() {
  		return nil, errors.Errorf("expected a pointer to a struct, got nil pointer")
  	}
  	valElem := val.Elem()
  	if valElem.Kind() != reflect.Struct {
  		return nil, errors.Errorf("expected a pointer to a struct, got a pointer to %v", valElem.Kind())
  	}
  	typ := val.Type()
  	m := make(map[string]interface{})
  	for i := 0; i < val.NumMethod(); i++ {
  		k, v, err := marshalForMethod(typ.Method(i), val.Method(i))
  		if err != nil {
  			return nil, err
  		}
  		if k != "" {
  			m[k] = v
  		}
  	}
  	return m, nil
  }
docs: // marshalMap marshals x to map[string]interface{}