feat: add the Document edit pipeline with comment-preserving write
Test / test (push) Successful in 1m35s

Assisted-by: GLM 5.3 Flash
This commit is contained in:
2026-09-22 01:22:46 +02:00
parent a7a942a8e1
commit 3ffae35a20
6 changed files with 488 additions and 23 deletions
+8 -2
View File
@@ -32,8 +32,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
values together with the key order, whether a table was written as an inline
table or under a header, and the comments, with `Keys`, `Entries`, `Get`,
`Comments` and `SetComments` to read and write them. `ParseMap` returns the
plain `map[string]any` tree, the shape `Parse` used to give. `Marshal` does
not accept a `Document`; it writes values, so `doc.Map()` is the way through.
plain `map[string]any` tree, the shape `Parse` used to give.
- The edit pipeline on a `Document`: typed getters on `Document` and `Table`
(`GetString`, `GetInt`, `GetFloat`, `GetBool`, `GetArray`, `GetTable`),
`Set` and `Delete` that keep the surviving keys' positions and comments,
`UnmarshalDocument`, which decodes the document into a typed destination
without parsing again, and `Marshal` of a `Document`, which writes the keys
in written order, the comments above the lines and headers they belonged
to, and the inline tables inline.
- `OffsetDateTime`, the Go type of the offset date-time kind, so that all four
TOML date-time kinds have one of their own. `Parse` and `Unmarshal` hand it
back where they produced a bare `time.Time` before, and `Marshal` accepts it.