func (f *defaultFormats) Parse(name, data string) (interface{}, error) {
	f.Lock()
	defer f.Unlock()
	nme := f.normalizeName(name)
	for _, v := range f.data {
		if v.Name == nme {
			nw := reflect.New(v.Type).Interface()
			if dec, ok := nw.(encoding.TextUnmarshaler); ok {
				if err := dec.UnmarshalText([]byte(data)); err != nil {
					return nil, err
				}
				return nw, nil
			}
			return nil, errors.InvalidTypeName(name)
		}
	}
	return nil, errors.InvalidTypeName(name)
}
func (f *defaultFormats) Parse(name, data string) (interface{}, error) {
	f.Lock()
	defer f.Unlock()
	nme := f.normalizeName(name)
	for _, v := range f.data {
		if v.Name == nme {
			nw := reflect.New(v.Type).Interface()
			if dec, ok := nw.(encoding.TextUnmarshaler); ok {
				if err := dec.UnmarshalText([]byte(data)); err != nil {
					return nil, err
				}
				return nw, nil
			}
			return nil, errors.InvalidTypeName(name)
		}
	}
	return nil, errors.InvalidTypeName(name)
}
func ( f * defaultFormats ) Parse ( name , data string ) ( interface { } , error ) { f . Lock ( ) defer f . Unlock ( ) nme := f . normalizeName ( name ) for _ , v := range f . data { if v . Name == nme { nw := reflect . New ( v . Type ) . Interface ( ) if dec , ok := nw . ( encoding . TextUnmarshaler ) ; ok { if err := dec . UnmarshalText ( [ ] byte ( data ) ) ; err != nil { return nil , err } return nw , nil } return nil , errors . InvalidTypeName ( name ) } } return nil , errors . InvalidTypeName ( name ) }
// Parse a string into the appropriate format representation type.
//
// E.g. parsing a string a "date" will return a Date type.
Parse a string into the appropriate format representation type . E . g . parsing a string a date will return a Date type .