Пример #1
0
// in: Linux/index.md
// out: ./MDFs
func modifiedMD(file_in, dir_out string) {
	finfo, err := os.Stat(file_in)
	if goutils.CheckErr(err) {
		return
	}
	filename := finfo.Name()
	dir := filepath.Dir(file_in)
	fs := strings.Split(filename, ".")
	in := goutils.ReadFile(file_in)
	out := make([]byte, 1)
	err = rpcsv.Markdown(rpc_client, &in, &out)
	if goutils.CheckErr(err) {
		return
	}
	// fmt.Println(goutils.ToString(out))
	target := fmt.Sprintf("%s.html", filepath.Join(dir_out, dir, fs[0]))

	goutils.Mkdir(fmt.Sprintf("%s", filepath.Join(dir_out, dir)))
	outfile, _ := os.OpenFile(fmt.Sprintf("%s.html", filepath.Join(dir_out, dir, fs[0])), os.O_CREATE|os.O_WRONLY, 0666)
	defer outfile.Close()
	dt := make(map[string]interface{})
	dt["MDContent"] = template.HTML(goutils.ToString(out))
	tpl.Execute(outfile, dt)
	fmt.Println(file_in, " ==> ", target)
}
Пример #2
0
func BenchmarkShort_Gsj(b *testing.B) {
	b.StopTimer()
	js, _ := gsj.NewJson(goutils.ReadFile("test.json"))
	b.StartTimer()
	for i := 0; i < b.N; i++ {
		_ = js.GetPath("Friends")
	}
}
Пример #3
0
func TestGsj(t *testing.T) {
	js, _ := gsj.NewJson(goutils.ReadFile("test.json"))
	name := js.GetPath("Friends", "One", "Name").MustString()
	assert(t, name, "One")
}