func pgids(t *bolt.Tx, indexes []int) ([]pgid, error) {
	tx := (*tx)(unsafe.Pointer(t))
	p := pageAt(t, tx.meta.root.root)
	ids := []pgid{tx.meta.root.root}
	for _, index := range indexes[1:] {
		if uint16(index) >= p.count {
			return nil, fmt.Errorf("out of range")
		}
		if (p.flags & branchPageFlag) != 0 {
			e := p.branchPageElement(uint16(index))
			ids = append(ids, e.pgid)
			p = pageAt(t, e.pgid)
		} else if (p.flags & leafPageFlag) != 0 {
			e := p.leafPageElement(uint16(index))
			if (e.flags & bucketLeafFlag) == 0 {
				return nil, fmt.Errorf("index not a bucket")
			}
			b := (*bucket)(unsafe.Pointer(&e.value()[0]))
			if (e.flags & bucketLeafFlag) == 0 {
				return nil, fmt.Errorf("index is an inline bucket")
			}
			ids = append(ids, b.root)
			p = pageAt(t, b.root)
		} else {
			return nil, fmt.Errorf("invalid page type: %s" + p.typ())
		}
	}
	return ids, nil
}
traverses the page hierarchy by index and returns associated page ids.
returns an error if an index is out of range.
package templates
import (
	"fmt"
	"math"
	"sort"
	"strconv"
	"strings"
	"unicode"
	"unicode/utf8"
	"unsafe"
	"github.com/boltdb/bolt"
)
func tostr(b []byte) string {
	if !utf8.Valid(b) {
		return fmt.Sprintf("%x", b)
	}
	var s = string(b)
	for _, ch := range s {
		if !unicode.IsPrint(ch) {
			return fmt.Sprintf("%x", b)
		}
	}
	return s
}
func trunc(s string, n int) string {
	if len(s) > n {
		return s[:n] + "..."
	}
	return s
}