feat(encode): write the TOML 1.1 output form

Assisted-by: DeepSeek V4.1 Flash
This commit is contained in:
2026-09-19 12:18:18 +02:00
parent bccaf087c8
commit 8f85bb68fa
8 changed files with 278 additions and 52 deletions
+6 -3
View File
@@ -232,7 +232,10 @@ type Unmarshaler interface {
// inline table.
// - Scalars encode as TOML scalars: bool, int64, float64, string, time.Time
// (offset date-time), and LocalDateTime/LocalDate/LocalTime (local
// variants).
// variants). A date-time writes its seconds only when the value carries
// them, and drops the trailing zeros of a fractional second.
// - A table element of a value array is written as an inline table, across
// lines when it does not fit one.
// - Values implementing Marshaler are encoded by calling MarshalTOML and
// using its result.
// - Values implementing encoding.TextMarshaler, and not one of the
@@ -261,8 +264,8 @@ func MarshalContext(ctx context.Context, v any) ([]byte, error) {
// An Encoder encodes Go values into TOML.
//
// All options default to the behaviour earlier releases used, and the defaults
// pass the toml-test compliance suite in both directions:
// All options default to the behaviour that passes the toml-test compliance
// suite in both directions:
//
// GroupByKind: true (scalars first, then tables, then arrays of tables)
// OmitEmptyArrays: false (a nil/empty []string slice emits [] as a value;