feat!: rework the public API to json/v2-style variadic options
Test / test (push) Successful in 1m49s

Assisted-by: GLM 5.3 Flash
This commit is contained in:
2026-09-22 18:42:18 +02:00
parent 7ee155d1e9
commit 2e61ad0ba9
18 changed files with 398 additions and 393 deletions
+12 -2
View File
@@ -111,12 +111,22 @@ func getEncoderBuf() *bytes.Buffer {
return b
}
// encodeConfig carries the public emission options one Marshal call applies;
// the names and defaults are documented on the MarshalOption constructors.
type encodeConfig struct {
layout LayoutKind
omitEmptyArrays bool
literalMultilineAt int
inlineTablesAt int
emitFieldComments bool
}
// encoder produces a TOML document from a Go value via a small intermediate
// representation that preserves the order in which fields were declared.
type encoder struct {
buf *bytes.Buffer
ctx context.Context
opts Encoder
opts encodeConfig
// inlineDepth is the nesting level inside inline tables, which decides
// their indentation.
@@ -329,7 +339,7 @@ type entry struct {
type tomlDoc struct {
entries []entry
ctx context.Context // inherited from encoder; nil-safe
opts Encoder // inherited from encoder; options drive emit-time behaviour
opts encodeConfig // inherited from encoder; options drive emit-time behaviour
depth int
}