本文整理汇总了Golang中github.com/google/badwolf/storage.Store.Name方法的典型用法代码示例。如果您正苦于以下问题:Golang Store.Name方法的具体用法?Golang Store.Name怎么用?Golang Store.Name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/google/badwolf/storage.Store
的用法示例。
在下文中一共展示了Store.Name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: REPL
// REPL starts a read-evaluation-print-loop to run BQL commands.
func REPL(driver storage.Store, input *os.File, rl ReadLiner, chanSize, bulkSize, builderSize int) int {
ctx := context.Background()
fmt.Printf("Welcome to BadWolf vCli (%d.%d.%d-%s)\n", version.Major, version.Minor, version.Patch, version.Release)
fmt.Printf("Using driver %q. Type quit; to exit\n", driver.Name(ctx))
fmt.Printf("Session started at %v\n\n", time.Now())
defer func() {
fmt.Printf("\n\nThanks for all those BQL queries!\n\n")
}()
fmt.Print(prompt)
l := ""
for line := range rl(input) {
nl := strings.TrimSpace(line)
if nl == "" {
fmt.Print(prompt)
continue
}
if l != "" {
l = l + " " + nl
} else {
l = nl
}
if !strings.HasSuffix(nl, ";") {
// Not done with the statement.
continue
}
if strings.HasPrefix(l, "quit") {
break
}
if strings.HasPrefix(l, "help") {
printHelp()
fmt.Print(prompt)
l = ""
continue
}
if strings.HasPrefix(l, "export") {
args := strings.Split("bw "+strings.TrimSpace(l[:len(l)-1]), " ")
usage := "Wrong syntax\n\n\tload <graph_names_separated_by_commas> <file_path>\n"
export.Eval(ctx, usage, args, driver, bulkSize)
fmt.Print(prompt)
l = ""
continue
}
if strings.HasPrefix(l, "load") {
args := strings.Split("bw "+strings.TrimSpace(l[:len(l)-1]), " ")
usage := "Wrong syntax\n\n\tload <file_path> <graph_names_separated_by_commas>\n"
load.Eval(ctx, usage, args, driver, bulkSize, builderSize)
fmt.Print(prompt)
l = ""
continue
}
if strings.HasPrefix(l, "run") {
path, cmds, err := runBQLFromFile(ctx, driver, chanSize, strings.TrimSpace(l[:len(l)-1]))
if err != nil {
fmt.Printf("[ERROR] %s\n\n", err)
} else {
fmt.Printf("Loaded %q and run %d BQL commands successfully\n\n", path, cmds)
}
fmt.Print(prompt)
l = ""
continue
}
table, err := runBQL(ctx, l, driver, chanSize)
l = ""
if err != nil {
fmt.Printf("[ERROR] %s\n\n", err)
} else {
if len(table.Bindings()) > 0 {
fmt.Println(table.String())
}
fmt.Println("[OK]")
}
fmt.Print(prompt)
}
return 0
}