diff --git a/ras/codec256/decode.go b/ras/codec256/decode.go index d4894ff..da86420 100644 --- a/ras/codec256/decode.go +++ b/ras/codec256/decode.go @@ -282,8 +282,18 @@ func ParseInt(r io.Reader, into interface{}) error { *typed = uint64(val) case *int64: *typed = int64(val) + case bool: + typed = false + if val == 1 { + typed = true + } + case *bool: + *typed = false + if val == 1 { + *typed = true + } default: - return &ParseError{"uint32", + return &ParseError{"int32", fmt.Sprintf("convert to <%s> unsupporsed", reflect.TypeOf(typed))} } return nil diff --git a/ras/codec256/encode.go b/ras/codec256/encode.go index b827995..9bbd156 100644 --- a/ras/codec256/encode.go +++ b/ras/codec256/encode.go @@ -148,6 +148,16 @@ func FormatInt(w io.Writer, value interface{}) error { val = uint32(*tVal) case *uint32: val = uint32(*tVal) + case bool: + val = uint32(0) + if tVal { + val = uint32(1) + } + case *bool: + val = uint32(0) + if *tVal { + val = uint32(1) + } default: return &TypeEncoderError{"int", "TODO"} }