func (any *Any) ParseTo(value interface{}) error {
	if any == nil {
		return errors.New("any is nil")
	}
	kind := reflect.TypeOf(value).Kind()
	if kind != reflect.Ptr || kind != reflect.Map {
		return errors.New("value must be pointer or map")
	}
	elemPtr := reflect.ValueOf(value)
	elem := elemPtr.Elem()
	elemKind := elem.Kind()
	switch anyVal := any.Value.(type) {
	case *Any_BoolValue:
		if elemKind != reflect.Bool {
			return errors.New("value type must be bool")
		}
		elem.SetBool(anyVal.BoolValue)
		return nil

	case *Any_Int32Value, *Any_Int64Value:
		if elemKind != reflect.Int &&
			elemKind != reflect.Int8 &&
			elemKind != reflect.Int16 &&
			elemKind != reflect.Int32 &&
			elemKind != reflect.Int64 {
			return errors.New("value type must be int")
		}
		if i32, ok := anyVal.(*Any_Int32Value); ok {
			elem.SetInt(int64(i32.Int32Value))
		} else {
			i64, _ := anyVal.(*Any_Int64Value)
			elem.SetInt(i64.Int64Value)
		}
		return nil

	case *Any_Uint32Value, *Any_Uint64Value:
		if elemKind != reflect.Uint &&
			elemKind != reflect.Uint8 &&
			elemKind != reflect.Uint16 &&
			elemKind != reflect.Uint32 &&
			elemKind != reflect.Uint64 {
			return errors.New("value type must be uint")
		}
		if i32, ok := anyVal.(*Any_Uint32Value); ok {
			elem.SetUint(uint64(i32.Uint32Value))
		} else {
			i64, _ := anyVal.(*Any_Uint64Value)
			elem.SetUint(i64.Uint64Value)
		}
		return nil

	case *Any_FloatValue, *Any_DoubleValue:
		if elemKind != reflect.Float32 &&
			elemKind != reflect.Float64 {
			return errors.New("value type must be float")
		}
		if i32, ok := anyVal.(*Any_FloatValue); ok {
			elem.SetFloat(float64(i32.FloatValue))
		} else {
			i64, _ := anyVal.(*Any_DoubleValue)
			elem.SetFloat(i64.DoubleValue)
		}
		return nil

	case *Any_StrValue:
		if elemKind != reflect.String {
			return errors.New("value type must be string")
		}
		elem.SetString(anyVal.StrValue)
		return nil

	case *Any_BinaryValue:
		if elemKind == reflect.Slice &&
			elem.Type().Elem().Kind() != reflect.Uint8 {
			return errors.New("value type must be []byte")
		}
		elem.SetBytes(anyVal.BinaryValue)
		return nil

	case *Any_MsgpackValue:
		err := msgpack.Unmarshal(anyVal.MsgpackValue, value)
		return err
	}
	return errors.New("undefined type")
}
// ParseTo parse any to value
ParseTo parse any to value
// ParseTo parse any to value
func (any *Any) ParseTo(value interface{}) error {
	if any == nil {
		return errors.New("any is nil")
	}
	kind := reflect.TypeOf(value).Kind()
	if kind != reflect.Ptr || kind != reflect.Map {
		return errors.New("value must be pointer or map")
	}
	elemPtr := reflect.ValueOf(value)
	elem := elemPtr.Elem()
	elemKind := elem.Kind()
	switch anyVal := any.Value.(type) {
	case *Any_BoolValue:
		if elemKind != reflect.Bool {
			return errors.New("value type must be bool")
		}
		elem.SetBool(anyVal.BoolValue)
		return nil
	case *Any_Int32Value, *Any_Int64Value:
		if elemKind != reflect.Int &&
			elemKind != reflect.Int8 &&
			elemKind != reflect.Int16 &&
			elemKind != reflect.Int32 &&
			elemKind != reflect.Int64 {
			return errors.New("value type must be int")
		}
		if i32, ok := anyVal.(*Any_Int32Value); ok {
			elem.SetInt(int64(i32.Int32Value))
		} else {
			i64, _ := anyVal.(*Any_Int64Value)
			elem.SetInt(i64.Int64Value)
		}
		return nil
	case *Any_Uint32Value, *Any_Uint64Value:
		if elemKind != reflect.Uint &&
			elemKind != reflect.Uint8 &&
			elemKind != reflect.Uint16 &&
			elemKind != reflect.Uint32 &&
			elemKind != reflect.Uint64 {
			return errors.New("value type must be uint")
		}
		if i32, ok := anyVal.(*Any_Uint32Value); ok {
			elem.SetUint(uint64(i32.Uint32Value))
		} else {
			i64, _ := anyVal.(*Any_Uint64Value)
			elem.SetUint(i64.Uint64Value)
		}
		return nil
	case *Any_FloatValue, *Any_DoubleValue:
		if elemKind != reflect.Float32 &&
			elemKind != reflect.Float64 {
			return errors.New("value type must be float")
		}
		if i32, ok := anyVal.(*Any_FloatValue); ok {
			elem.SetFloat(float64(i32.FloatValue))
		} else {
			i64, _ := anyVal.(*Any_DoubleValue)
			elem.SetFloat(i64.DoubleValue)
		}
		return nil
	case *Any_StrValue:
		if elemKind != reflect.String {
			return errors.New("value type must be string")
		}
		elem.SetString(anyVal.StrValue)
		return nil
	case *Any_BinaryValue:
		if elemKind == reflect.Slice &&
			elem.Type().Elem().Kind() != reflect.Uint8 {
			return errors.New("value type must be []byte")
		}
		elem.SetBytes(anyVal.BinaryValue)
		return nil
	case *Any_MsgpackValue:
		err := msgpack.Unmarshal(anyVal.MsgpackValue, value)
		return err
	}
	return errors.New("undefined type")
}
func ( any * Any ) ParseTo ( value interface { } ) error { if any == nil { return errors . New ( " " ) } kind := reflect . TypeOf ( value ) . Kind ( ) if kind != reflect . Ptr || kind != reflect . Map { return errors . New ( " " ) } elemPtr := reflect . ValueOf ( value ) elem := elemPtr . Elem ( ) elemKind := elem . Kind ( ) switch anyVal := any . Value . ( type ) { case * Any_BoolValue : if elemKind != reflect . Bool { return errors . New ( " " ) } elem . SetBool ( anyVal . BoolValue ) return nil case * Any_Int32Value , * Any_Int64Value : if elemKind != reflect . Int && elemKind != reflect . Int8 && elemKind != reflect . Int16 && elemKind != reflect . Int32 && elemKind != reflect . Int64 { return errors . New ( " " ) } if i32 , ok := anyVal . ( * Any_Int32Value ) ; ok { elem . SetInt ( int64 ( i32 . Int32Value ) ) } else { i64 , _ := anyVal . ( * Any_Int64Value ) elem . SetInt ( i64 . Int64Value ) } return nil case * Any_Uint32Value , * Any_Uint64Value : if elemKind != reflect . Uint && elemKind != reflect . Uint8 && elemKind != reflect . Uint16 && elemKind != reflect . Uint32 && elemKind != reflect . Uint64 { return errors . New ( " " ) } if i32 , ok := anyVal . ( * Any_Uint32Value ) ; ok { elem . SetUint ( uint64 ( i32 . Uint32Value ) ) } else { i64 , _ := anyVal . ( * Any_Uint64Value ) elem . SetUint ( i64 . Uint64Value ) } return nil case * Any_FloatValue , * Any_DoubleValue : if elemKind != reflect . Float32 && elemKind != reflect . Float64 { return errors . New ( " " ) } if i32 , ok := anyVal . ( * Any_FloatValue ) ; ok { elem . SetFloat ( float64 ( i32 . FloatValue ) ) } else { i64 , _ := anyVal . ( * Any_DoubleValue ) elem . SetFloat ( i64 . DoubleValue ) } return nil case * Any_StrValue : if elemKind != reflect . String { return errors . New ( " " ) } elem . SetString ( anyVal . StrValue ) return nil case * Any_BinaryValue : if elemKind == reflect . Slice && elem . Type ( ) . Elem ( ) . Kind ( ) != reflect . Uint8 { return errors . New ( " " ) } elem . SetBytes ( anyVal . BinaryValue ) return nil case * Any_MsgpackValue : err := msgpack . Unmarshal ( anyVal . MsgpackValue , value ) return err } return errors . New ( " " ) }
ParseTo parse any to value
ParseTo parse any to value