The tree is a pager plus the page id of its root. Today you create one - a brand-new tree whose root is a single empty leaf page - giving the index a real, importable shape that every later lesson thickens.
Create a tree over a pager whose root is a freshly allocated, empty leaf page.
A B+Tree is two things: a pager to hold its pages and the page id of its root. Everything else - search, insert, delete - starts by reading the root page and follows child ids down from there. A fresh tree has the simplest possible shape: a single leaf, empty, that is both the root and the only leaf.
Storing the root as a page id rather than a pointer is the small decision that keeps the tree disk-ready. When the root splits later, the tree just records a new root id; when the tree is reopened from a file, it reads the root id out of the meta page. The root is never an object you hold onto - it is always a number you look up through the pager, exactly like every other node.
type Tree struct { pager Pager; root PageID }func NewTree(p Pager) *Tree {id := p.AllocPage()p.WritePage(id, serializeLeaf(&LeafNode{})) // empty leafreturn &Tree{pager: p, root: id}}