func ListStringToValues(lst []string) []Value {
	if lst == nil {
		return []Value{}
	}
	newLst := make([]Value, len(lst))
	for i := 0; i < len(lst); i++ {
		newLst[i] = NewValue(lst[i])
	}
	return newLst
}
ListStringToValues converts a []string to []Value.
package util
import (
	"errors"
	"time"
	"github.com/deejross/mydis/pb"
	"github.com/gogo/protobuf/proto"
)
type Value struct {
	err error
	b   []byte
}
func NewValue(t interface{}) Value {
	switch t := t.(type) {
	case error:
		return Value{err: t}
	case Value:
		return t
	case []byte:
		return Value{b: t}
	case string:
		return Value{b: StringToBytes(t)}
	case bool:
		if t {
			return Value{b: []byte{1}}
		}
		return Value{b: ZeroByte}
	case proto.Message:
		b, _ := proto.Marshal(t)
		return Value{b: b}
	case int:
		b, _ := proto.Marshal(&pb.IntValue{Value: int64(t)})
		return Value{b: b}
	case int8:
		b, _ := proto.Marshal(&pb.IntValue{Value: int64(t)})
		return Value{b: b}
	case int16:
		b, _ := proto.Marshal(&pb.IntValue{Value: int64(t)})
		return Value{b: b}
	case int32:
		b, _ := proto.Marshal(&pb.IntValue{Value: int64(t)})
		return Value{b: b}
	case int64:
		b, _ := proto.Marshal(&pb.IntValue{Value: t})
		return Value{b: b}
	case float32:
		b, _ := proto.Marshal(&pb.FloatValue{Value: float64(t)})
		return Value{b: b}
	case float64:
		b, _ := proto.Marshal(&pb.FloatValue{Value: t})
		return Value{b: b}
	case time.Time:
		b, _ := proto.Marshal(&pb.IntValue{Value: int64(t.Nanosecond())})
		return Value{b: b}
	case time.Duration:
		b, _ := proto.Marshal(&pb.IntValue{Value: t.Nanoseconds()})
		return Value{b: b}
	case [][]byte:
		b, _ := proto.Marshal(&pb.List{Value: t})
		return Value{b: b}
	case []string:
		b, _ := proto.Marshal(&pb.List{Value: ListStringToBytes(t)})
		return Value{b: b}
	case []Value:
		b, _ := proto.Marshal(&pb.List{Value: ListValueToBytes(t)})
		return Value{b: b}
	case map[string]string:
		b, _ := proto.Marshal(&pb.Hash{Value: MapStringToMapBytes(t)})
		return Value{b: b}
	case map[string][]byte:
		b, _ := proto.Marshal(&pb.Hash{Value: t})
		return Value{b: b}
	case map[string]bool:
		b, _ := proto.Marshal(&pb.Hash{Value: MapBoolToMapBytes(t)})
		return Value{b: b}
	case map[string]int64:
		b, _ := proto.Marshal(&pb.Hash{Value: MapIntToMapBytes(t)})
		return Value{b: b}
	case map[string]float64:
		b, _ := proto.Marshal(&pb.Hash{Value: MapFloatToMapBytes(t)})
		return Value{b: b}
	case map[string]Value:
		b, _ := proto.Marshal(&pb.Hash{Value: MapValueToMapBytes(t)})
		return Value{b: b}
	default:
		return Value{err: errors.New("Unknown type, recommend marshalling to byte slice")}
	}
}
func (v Value) Error() error {
	return v.err
}
func (v Value) Bytes() ([]byte, error) {
	if v.err != nil {
		return nil, v.err
	}
	return v.b, nil
}
func (v Value) RawBytes() []byte {
	return v.b
}
func (v Value) String() (string, error) {
	if v.err != nil {
		return "", v.err
	}
	return BytesToString(v.b), nil
}
func (v Value) Bool() (bool, error) {
	if v.err != nil {
		return false, v.err
	}
	if len(v.b) > 0 && v.b[0] != 0 {
		return true, nil
	}
	return false, nil
}
func (v Value) Proto(pb proto.Message) error {
	if v.err != nil {
		return v.err
	}
	if pb == nil {
		return nil
	}
	err := proto.Unmarshal(v.b, pb)
	if err != nil {
		return err
	}
	return nil
}
func (v Value) Int() (int64, error) {
	iv := &pb.IntValue{}
	if err := v.Proto(iv); err != nil {
		return 0, err
	}
	return iv.Value, nil
}
func (v Value) Float() (float64, error) {
	fv := &pb.FloatValue{}
	if err := v.Proto(fv); err != nil {
		return 0, err
	}
	return fv.Value, nil
}
func (v Value) Time() (time.Time, error) {
	iv := &pb.IntValue{}
	if err := v.Proto(iv); err != nil {
		return time.Time{}, err
	}
	return time.Unix(0, iv.Value), nil
}
func (v Value) Duration() (time.Duration, error) {
	iv := &pb.IntValue{}
	if err := v.Proto(iv); err != nil {
		return 0, err
	}
	return time.Duration(iv.Value), nil
}
func (v Value) List() ([]Value, error) {
	lst := &pb.List{}
	if err := v.Proto(lst); err != nil {
		return nil, err
	}
	return ListToValues(lst.Value), nil
}
func (v Value) Map() (map[string]Value, error) {
	h := &pb.Hash{}
	if err := v.Proto(h); err != nil {
		return nil, err
	}
	return MapBytesToValues(h.Value), nil
}
func ListToValues(lst [][]byte) []Value {
	if lst == nil {
		return []Value{}
	}
	newLst := make([]Value, len(lst))
	for i := 0; i < len(lst); i++ {
		newLst[i] = NewValue(lst[i])
	}
	return newLst
}