-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathembed.go
43 lines (35 loc) · 793 Bytes
/
embed.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
// Embed Tipiṭaka ToC JSON in Go code
import (
"flag"
"fmt"
"io/ioutil"
"os"
"path"
"github.com/siongui/goef"
"github.com/siongui/gopalilib/tpkutil"
"github.com/siongui/gopalilib/util"
)
func SaveTipitakaTreeJson(xmldir, outputdir string) {
fmt.Println(xmldir)
t, err := tpkutil.BuildTipitakaTree(xmldir)
if err != nil {
panic(err)
}
//fmt.Println(t)
util.SaveJsonFile(t, path.Join(outputdir, "tpktoc.json"))
}
func main() {
xmlDir := flag.String("xmlDir", "", "Tipiṭaka XML dir")
flag.Parse()
dir, err := ioutil.TempDir("", "tocjson")
if err != nil {
panic(err)
}
defer os.RemoveAll(dir) // clean up
SaveTipitakaTreeJson(*xmlDir, dir)
err = goef.GenerateGoPackagePlainText("main", dir, "gopherjs/data.go")
if err != nil {
panic(err)
}
}