add codec.RawMessage support
All checks were successful
test / test (push) Successful in 3m25s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2024-12-23 20:57:22 +03:00
parent 3dac202602
commit efb75b8357
3 changed files with 22 additions and 1558 deletions

10
xml.go
View File

@@ -40,6 +40,10 @@ func (c *xmlCodec) Marshal(v interface{}, opts ...codec.Option) ([]byte, error)
return m.Data, nil
case *pb.Frame:
return m.Data, nil
case codec.RawMessage:
return []byte(m), nil
case *codec.RawMessage:
return []byte(*m), nil
}
return xml.Marshal(v)
@@ -68,6 +72,12 @@ func (c *xmlCodec) Unmarshal(b []byte, v interface{}, opts ...codec.Option) erro
case *pb.Frame:
m.Data = b
return nil
case *codec.RawMessage:
*m = append((*m)[0:0], b...)
return nil
case codec.RawMessage:
copy(m, b)
return nil
}
return xml.Unmarshal(b, v)