feat: add OrderedMap, the table that keeps its key order
Test / test (push) Successful in 1m30s

Assisted-by: GLM 5.3 Flash
This commit is contained in:
2026-09-22 00:15:17 +02:00
parent aefff80a28
commit eaa69dc6f6
8 changed files with 567 additions and 8 deletions
+7
View File
@@ -18,9 +18,13 @@ import (
// decoder maps a parsed TOML tree onto Go values via reflection. ctx is the
// context a cancellable entry point handed in, and reaches an
// UnmarshalerContext destination; entry points without one leave it nil.
// nodes is the document's node index, present only when a destination can
// reach an OrderedMap and the parse built the tree its key order is read
// from.
type decoder struct {
disallowUnknown bool
ctx context.Context
nodes nodeIndex
}
func newDecoder() *decoder { return &decoder{} }
@@ -273,6 +277,9 @@ func textUnmarshalerOf(dst reflect.Value) (encoding.TextUnmarshaler, bool) {
}
func (d *decoder) assignTable(tbl map[string]any, dst reflect.Value) error {
if dst.Type() == orderedMapType {
return d.fillOrderedMap(tbl, dst)
}
switch dst.Kind() {
case reflect.Struct:
return d.assignStruct(tbl, dst)