func parseValue()

in common/config/keys_tree.go [121:218]


func parseValue(val string, toType reflect.Kind) interface{} {
	switch toType {
	case reflect.Bool:
		parsed, err := strconv.ParseBool(val)
		if err != nil {
			return nil
		}
		return parsed
	case reflect.Int:
		parsed, err := strconv.ParseInt(val, 0, 0)
		if err != nil {
			return nil
		}
		return int(parsed)
	case reflect.Int8:
		parsed, err := strconv.ParseInt(val, 0, 8)
		if err != nil {
			return nil
		}
		return int8(parsed)
	case reflect.Int16:
		parsed, err := strconv.ParseInt(val, 0, 16)
		if err != nil {
			return nil
		}
		return int16(parsed)
	case reflect.Int32:
		parsed, err := strconv.ParseInt(val, 0, 32)
		if err != nil {
			return nil
		}
		return int32(parsed)
	case reflect.Int64:
		parsed, err := strconv.ParseInt(val, 0, 64)
		if err != nil {
			return nil
		}
		return int64(parsed)
	case reflect.Uint:
		parsed, err := strconv.ParseUint(val, 0, 0)
		if err != nil {
			return nil
		}
		return uint(parsed)
	case reflect.Uint8:
		parsed, err := strconv.ParseUint(val, 0, 8)
		if err != nil {
			return nil
		}
		return uint8(parsed)
	case reflect.Uint16:
		parsed, err := strconv.ParseUint(val, 0, 16)
		if err != nil {
			return nil
		}
		return uint16(parsed)
	case reflect.Uint32:
		parsed, err := strconv.ParseUint(val, 0, 32)
		if err != nil {
			return nil
		}
		return uint32(parsed)
	case reflect.Uint64:
		parsed, err := strconv.ParseUint(val, 0, 64)
		if err != nil {
			return nil
		}
		return uint64(parsed)
	case reflect.Float32:
		parsed, err := strconv.ParseFloat(val, 32)
		if err != nil {
			return nil
		}
		return float32(parsed)
	case reflect.Float64:
		parsed, err := strconv.ParseFloat(val, 64)
		if err != nil {
			return nil
		}
		return float64(parsed)
	case reflect.Complex64:
		parsed, err := strconv.ParseComplex(val, 64)
		if err != nil {
			return nil
		}
		return complex64(parsed)
	case reflect.Complex128:
		parsed, err := strconv.ParseComplex(val, 128)
		if err != nil {
			return nil
		}
		return complex128(parsed)
	case reflect.String:
		return val
	default:
		return nil
	}
}