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
}
Bool returns the Value as bool.
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
}