+18
-12
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Added
|
||||
|
||||
-
|
||||
|
||||
## [2.0.0] - 2026-09-22
|
||||
|
||||
### Added
|
||||
|
||||
- `encoding.TextMarshaler` and `encoding.TextUnmarshaler` are honoured by
|
||||
default, with no option to switch them off. A type that implements them is
|
||||
encoded as a TOML string and decoded from one: `net.IP` becomes
|
||||
@@ -20,7 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- `time.Duration` is encoded in its canonical Go form as a TOML string,
|
||||
`1h30m0s`, because TOML has no duration type; the decoder reads that string
|
||||
back and still accepts a bare integer as the nanosecond count.
|
||||
- `interpres-decode -encode`, the adapter's other direction: it reads the
|
||||
- `interpres-decode --encode`, the adapter's other direction: it reads the
|
||||
toml-test tagged JSON from stdin and writes the TOML document it describes.
|
||||
The compliance suite now runs the encoder as well as the decoder, 214
|
||||
encoder cases against the tagged JSON of the valid corpus.
|
||||
@@ -47,8 +53,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
the plain type takes an offset date-time as it always did; code that asserts
|
||||
the tree's type, and `UnmarshalTOML` implementations that expect a
|
||||
`time.Time`, need the new type.
|
||||
- `MaxNestingDepth(depth)` and `MaxInputSize(size)` options bound the parse a
|
||||
`Decode` performs, and every parse carries a nesting limit in any case
|
||||
- `MaxNestingDepth(depth)` and `MaxInputSize(size)` options bound the parse an
|
||||
`Unmarshal` performs, and every parse carries a nesting limit in any case
|
||||
(10000 levels, which no hand-written document approaches): a document that
|
||||
nests arrays or inline tables deeper used to run the stack out and is now
|
||||
rejected with a `SyntaxError` naming the limit.
|
||||
@@ -57,7 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
header as one statement with its node, an `[[array of tables]]` as one
|
||||
statement per element. A caller that breaks after the statement it wanted
|
||||
reads no further ones. `examples/statements` shows the walk.
|
||||
- `ParseAs[T](data)`, the generic one-line decode, and `NewSchema[T]()`,
|
||||
- `ParseAs[T](data, opts...)`, the generic one-line decode, and `NewSchema[T]()`,
|
||||
which precompiles the struct schema and the interface flags for a hot path
|
||||
before the first document arrives.
|
||||
- `EmitFieldComments(true)` prints the comment a field's `toml` tag
|
||||
@@ -101,26 +107,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
is an error wrapped with the key path.
|
||||
- `MarshalAppend(buf, v)` appends the TOML encoding of v to buf and returns
|
||||
the extended buffer, the shape `json.MarshalAppend` has.
|
||||
- `interpres-decode -version` prints the binary's version, the module version
|
||||
- `interpres-decode --version` prints the binary's version, the module version
|
||||
the toolchain recorded, so a release-built binary names its own tag.
|
||||
- `interpres-decode -json` prints plain indented JSON instead of the tagged
|
||||
- `interpres-decode --json` prints plain indented JSON instead of the tagged
|
||||
form, the shape for people and diffs, with the date-time wrappers in their
|
||||
TOML form.
|
||||
- `interpres-decode -validate` walks a named directory for `.toml` files and
|
||||
- `interpres-decode --validate` walks a named directory for `.toml` files and
|
||||
closes the sweep with a summary naming how many documents were checked and
|
||||
how many were invalid; single files stay quiet on success as before.
|
||||
- `interpres-decode -struct` infers a Go struct definition from a document:
|
||||
- `interpres-decode --struct` infers a Go struct definition from a document:
|
||||
one field per key in written order, nested tables as nested struct types,
|
||||
an array of tables as a slice. The printed type compiles and decodes the
|
||||
document it came from.
|
||||
- `interpres-decode -schema TYPE file.go` writes a TOML template for the
|
||||
- `interpres-decode --schema TYPE file.go` writes a TOML template for the
|
||||
named struct type of a Go source, the `comment=` tag option printed as a
|
||||
comment and the `default=` option as the value. It is the inverse of
|
||||
`-struct`.
|
||||
`--struct`.
|
||||
- `ParseFile(path)` reads the file and parses it into a `Document`, with the
|
||||
file name at the front of every error it returns, read failure and parse
|
||||
failure alike. `Valid(data)` reports whether a document parses, nil on
|
||||
success and the parse error on failure, the library call the `-validate`
|
||||
success and the parse error on failure, the library call the `--validate`
|
||||
mode of interpres-decode is built on.
|
||||
- `SyntaxError` carries the byte `Offset` the scan stopped at and the 1-based
|
||||
`Column` on the line, beside the line it always had, and `SourceLine(src)`
|
||||
@@ -328,7 +334,7 @@ except where noted above.
|
||||
comments and trailing commas. The compliance suite runs in TOML 1.1 mode:
|
||||
214 valid and 467 invalid cases, zero failures. Every TOML 1.0 document
|
||||
parses exactly as before.
|
||||
- `interpres-decode -validate [file ...]`: a validate mode beside the
|
||||
- `interpres-decode --validate [file ...]`: a validate mode beside the
|
||||
toml-test adapter. It parses each named file, or stdin when none are named,
|
||||
prints one line per invalid document to stderr, and exits 0 when all are
|
||||
valid, 1 when one is not, and 2 on a usage or read failure. Install it with
|
||||
|
||||
Reference in New Issue
Block a user