func (d *dawg) Print() {
	DumpFile(d.r)
}
Print will print all edges to the standard output
package dawg
import (
	"bytes"
	"errors"
	"fmt"
	"io"
	"log"
	"strconv"
)
type FindResult struct {
	Word  string
	Index int
}
type edgeStart struct {
	node int
	ch   rune
}
func (edge edgeStart) String() string {
	return fmt.Sprintf("(%d, '%c')", edge.node, edge.ch)
}
type edgeEnd struct {
	node  int
	count int
}
type uncheckedNode struct {
	parent int
	ch     rune
	child  int
}
type EnumFn = func(index int, word []rune, final bool) EnumerationResult
type EnumerationResult = int
const (
	Continue EnumerationResult = iota
	Skip
	Stop
)
type Finder interface {
	FindAllPrefixesOf(input string) []FindResult
	IndexOf(input string) int
	AtIndex(index int) (string, error)
	Enumerate(fn EnumFn)
	NumAdded() int
	NumEdges() int
	NumNodes() int
	Print()
	Close() error
	Write(w io.Writer) (int64, error)
	Save(filename string) (int64, error)
}
type Builder interface {
	Add(wordIn string)
	CanAdd(word string) bool
	Finish() Finder
}
const rootNode = 0
type node struct {
	final bool
	count int
	edges []edgeStart
}
type dawg struct {
	lastWord       []rune
	nextID         int
	uncheckedNodes []uncheckedNode
	minimizedNodes map[string]int
	nodes          map[int]*node
	r    io.ReaderAt
	size int64  
	finished        bool
	numAdded        int
	numNodes        int
	numEdges        int
	cbits           int64  
	abits           int64  
	wbits           int64  
	firstNodeOffset int64  
	hasEmptyWord    bool
}
func New() Builder {
	return &dawg{
		nextID:         1,
		minimizedNodes: make(map[string]int),
		nodes: map[int]*node{
			0: {count: -1},
		},
	}
}
func (d *dawg) CanAdd(word string) bool {
	return !d.finished &&
		(d.numAdded == 0 || word > string(d.lastWord))
}
func (d *dawg) Add(wordIn string) {
	if d.numAdded > 0 && wordIn <= string(d.lastWord) {
		log.Printf("Last word=%s newword=%s", string(d.lastWord), wordIn)
		panic(errors.New("d.AddWord(): Words not in alphabetical order"))
	} else if d.finished {
		panic(errors.New("d.AddWord(): Tried to add to a finished dawg"))
	}
	word := []rune(wordIn)
	commonPrefix := 0
	for i := 0; i < min(len(word), len(d.lastWord)); i++ {
		if word[i] != d.lastWord[i] {
			break
		}
		commonPrefix++
	}
	d.minimize(commonPrefix)
	var node int
	if len(d.uncheckedNodes) == 0 {
		node = rootNode
	} else {
		node = d.uncheckedNodes[len(d.uncheckedNodes)-1].child
	}
	for _, letter := range word[commonPrefix:] {
		nextNode := d.newNode()
		d.addChild(node, letter, nextNode)
		d.uncheckedNodes = append(d.uncheckedNodes, uncheckedNode{node, letter, nextNode})
		node = nextNode
	}
	d.setFinal(node)
	d.lastWord = word
	d.numAdded++
}
func (d *dawg) Finish() Finder {
	if !d.finished {
		d.finished = true
		d.minimize(0)
		d.numNodes = len(d.minimizedNodes) + 1
		d.calculateSkipped(rootNode)
		d.uncheckedNodes = nil
		d.minimizedNodes = nil
		d.lastWord = nil
		d.renumber()
		var buffer bytes.Buffer
		d.size, _ = d.Write(&buffer)
		d.r = bytes.NewReader(buffer.Bytes())
		d.nodes = nil
	}
	finder, _ := Read(d.r, 0)
	return finder
}
func (d *dawg) renumber() {
	remap := make(map[int]int)
	var process func(id int)
	process = func(id int) {
		if _, ok := remap[id]; ok {
			return
		}
		remap[id] = len(remap)
		node := d.nodes[id]
		for _, edge := range node.edges {
			process(edge.node)
		}
	}
	process(rootNode)
	nodes := make(map[int]*node)
	for id, node := range d.nodes {
		nodes[remap[id]] = node
		for i := range node.edges {
			node.edges[i].node = remap[node.edges[i].node]
		}
	}
	d.nodes = nodes
}