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

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2024-12-23 21:01:38 +03:00
parent e0d6f2552c
commit dd86ed313e
3 changed files with 29 additions and 1547 deletions

10
yaml.go
View File

@@ -35,6 +35,10 @@ func (c *yamlCodec) 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 yaml.Marshal(v)
@@ -63,6 +67,12 @@ func (c *yamlCodec) Unmarshal(b []byte, v interface{}, opts ...codec.Option) err
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 yaml.Unmarshal(b, v)