code: func GenerateFromModel(options Generic, model interface{}) (interface{}, error) {
  	modType := reflect.TypeOf(model)
  
  	// If the model is of pointer type, we need to dereference for New.
  	resType := reflect.TypeOf(model)
  	if modType.Kind() == reflect.Ptr {
  		resType = resType.Elem()
  	}
  
  	// Populate the result structure with the generic layout content.
  	res := reflect.New(resType)
  	for name, value := range options {
  		field := res.Elem().FieldByName(name)
  		if !field.IsValid() {
  			return nil, NoSuchFieldError{name, resType.String()}
  		}
  		if !field.CanSet() {
  			return nil, CannotSetFieldError{name, resType.String()}
  		}
  		if reflect.TypeOf(value) != field.Type() {
  			return nil, TypeMismatchError{name, field.Type().String(), reflect.TypeOf(value).String()}
  		}
  		field.Set(reflect.ValueOf(value))
  	}
  
  	// If the model is not of pointer type, return content of the result.
  	if modType.Kind() == reflect.Ptr {
  		return res.Interface(), nil
  	}
  	return res.Elem().Interface(), nil
  }
docs: // GenerateFromModel takes the generic options, and tries to build a new
  // instance of the model's type by matching keys from the generic options to
  // fields in the model.
  //
  // The return value is of the same type than the model (including a potential
  // pointer qualifier).