// Unmarshal transforms a string->string map into a custom struct.
Unmarshal transforms a string->string map into a custom struct.
// Unmarshal transforms a string - > string map into a custom struct .
func Unmarshal(m map[string]string, data interface{}) (err error) {
	defer func() {
		if r := recover(); r != nil {
			err = fmt.Errorf("%v: %w", r, ErrMapUnmarshal)
		}
	}()
	if len(m) == 0 {
		return nil
	}
	rv := reflect.ValueOf(data)
	el := rv.Elem()
	elT := el.Type()
	for i := 0; i < el.NumField(); i++ {
		field := el.Field(i)
		ftype := elT.Field(i)
		tag := ftype.Tag.Get("map")
		val := m[tag]
		field.SetString(val)
	}
	return
}
func Unmarshal ( m map [ string ] string , data interface { } ) ( err error ) { defer func ( ) { if r := recover ( ) ; r != nil { err = fmt . Errorf ( " " , r , ErrMapUnmarshal ) } } ( ) if len ( m ) == 0 { return nil } rv := reflect . ValueOf ( data ) el := rv . Elem ( ) elT := el . Type ( ) for i := 0 ; i < el . NumField ( ) ; i ++ { field := el . Field ( i ) ftype := elT . Field ( i ) tag := ftype . Tag . Get ( " " ) val := m [ tag ] field . SetString ( val ) } return }
Unmarshal transforms a string->string map into a custom struct.
Unmarshal transforms a string - > string map into a custom struct .
// Exit if the map is empty.