RawMessage support

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2026-03-09 18:52:37 +03:00
parent 73d616e3d0
commit 35d22d9f8b
4 changed files with 61 additions and 40 deletions

View File

@@ -39,6 +39,8 @@ func (c *yamlCodec) Marshal(v interface{}, opts ...codec.Option) ([]byte, error)
return []byte(m), nil
case *codec.RawMessage:
return []byte(*m), nil
case yaml.RawMessage:
return []byte(m), nil
}
return yaml.Marshal(v)
@@ -73,6 +75,12 @@ func (c *yamlCodec) Unmarshal(b []byte, v interface{}, opts ...codec.Option) err
case codec.RawMessage:
copy(m, b)
return nil
case yaml.RawMessage:
copy(m, b)
return nil
case *yaml.RawMessage:
*m = append((*m)[0:0], b...)
return nil
}
return yaml.Unmarshal(b, v)