...
1
2
3
4
5
6
7 package triegen_test
8
9
10
11
12
13
14
15
16 import (
17 "log"
18 "os"
19 "os/exec"
20 )
21
22 func init() {
23 const tmpfile = "tmpout"
24 const dstfile = "data_test.go"
25
26 f, err := os.Create(tmpfile)
27 if err != nil {
28 log.Fatalf("Could not create output file: %v", err)
29 }
30 defer os.Remove(tmpfile)
31 defer f.Close()
32
33
34
35
36 genWriter = f
37
38 f.Write([]byte(header))
39
40 Example_build()
41 ExampleGen_build()
42
43 if err := exec.Command("gofmt", "-w", tmpfile).Run(); err != nil {
44 log.Fatal(err)
45 }
46 os.Remove(dstfile)
47 os.Rename(tmpfile, dstfile)
48
49 os.Exit(0)
50 }
51
52 const header = `// This file is generated with "go test -tags generate". DO NOT EDIT!
53 //go:build !generate
54
55 package triegen_test
56 `
57
58
59
60
61
62 type trie struct{}
63
64 func (t *trie) lookupString(string) (uint8, int) { return 0, 1 }
65 func (t *trie) lookupStringUnsafe(string) uint64 { return 0 }
66
67 func newRandTrie(i int) *trie { return &trie{} }
68 func newMultiTrie(i int) *trie { return &trie{} }
69
View as plain text