MCPcopy
hub / github.com/davyxu/tabtoy / LoadSpecifiedTable

Function LoadSpecifiedTable

v3/example/golang/main.go:39–64  ·  view source on GitHub ↗

按指定表加载

()

Source from the content-addressed store, hash-verified

37
38// 按指定表加载
39func LoadSpecifiedTable() {
40 var TabData = NewTable()
41 err := tabtoy.LoadTableFromFile(TabData, "../jsondir/ExampleData.json")
42 if err != nil {
43 fmt.Println(err)
44 os.Exit(1)
45 }
46
47 fmt.Println("load specified table: ExampleData")
48 for k, v := range TabData.ExampleDataByID {
49 fmt.Println(k, v)
50 }
51
52 // 分表加载时, 不会触发pre/post Handler
53 var TabKV = NewTable()
54 err = tabtoy.LoadTableFromFile(TabKV, "../jsondir/ExampleKV.json")
55 if err != nil {
56 fmt.Println(err)
57 os.Exit(1)
58 }
59
60 fmt.Println("load specified table: ExampleKV")
61 for k, v := range TabKV.ExampleKV {
62 fmt.Println(k, v)
63 }
64}
65
66func main() {
67 LoadAllTable()

Callers 1

mainFunction · 0.70

Calls 1

NewTableFunction · 0.70

Tested by

no test coverage detected