The final lesson runs the whole library on a realistic multi-section config that uses every feature, parsing it into one exact nested document and proving every layer works together.
Parse a full configuration with every value type into the exact nested tree.
This is the promise the whole project was built to keep: a real, importable TOML
library. Give it a configuration that uses everything - a top-level title and
enabled, an [owner] table with a datetime, a [database] table with an integer,
a hex integer, a float, and an array, a nested [servers.alpha] header, two
[[products]] elements one of which holds an inline table, and a [notes] table
with a multiline basic string - and it parses the text into one nested tree of typed
values. Every value form, every table shape, and the current-table machinery all
run at once.
The line reader skipped comments and blanks, the value dispatch told strings from
numbers from dates, the string readers applied their trims and escapes, and the
header and dotted-key logic assembled the nested document while catching any
duplicate or conflict. From a parser that read one key = value line into a flat
table you have built the honest core of a TOML library - the same design that sits
inside the configuration loaders you use every day, minus the serializer and the
rarest conformance corners. The finalize pass wraps this in a small command that
pretty-prints any config from the shell; the engine underneath is entirely yours.
// doc, err := Parse(source) // the whole multi-section config; err is nil// v, _ := doc.Get("database"); db := v.Tbl// db.Get("mask") -> KindInteger 57005 (0xDEAD)// p, _ := doc.Get("products"); p.Arr[1].Tbl.Get("color") -> inline table// n := notes.Get("text") -> "line one\nline two\n"