feat: decode arrays into [N]T and add MarshalAppend
Test / test (push) Successful in 2m31s

Assisted-by: GLM 5.3 Flash
This commit is contained in:
2026-09-21 23:58:23 +02:00
parent 10d49fbe60
commit 2e5dfc54c9
6 changed files with 140 additions and 18 deletions
+11
View File
@@ -399,6 +399,17 @@ func Marshal(v any) ([]byte, error) {
return MarshalContext(context.Background(), v)
}
// MarshalAppend appends the TOML encoding of v to buf and returns the extended
// buffer, the shape json.MarshalAppend has. A failed encoding leaves buf
// untouched and comes back with a nil slice.
func MarshalAppend(buf []byte, v any) ([]byte, error) {
out, err := Marshal(v)
if err != nil {
return nil, err
}
return append(buf, out...), nil
}
// MarshalContext is the cancellable variant of Marshal.
func MarshalContext(ctx context.Context, v any) ([]byte, error) {
if err := ctx.Err(); err != nil {