当前位置: 首页>>代码示例>>Golang>>正文


Golang Store.Name方法代码示例

本文整理汇总了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
}
开发者ID:google,项目名称:badwolf,代码行数:77,代码来源:repl.go


注:本文中的github.com/google/badwolf/storage.Store.Name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。