本文整理匯總了Golang中github.com/google/cayley/query.Session.Debug方法的典型用法代碼示例。如果您正苦於以下問題:Golang Session.Debug方法的具體用法?Golang Session.Debug怎麽用?Golang Session.Debug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/cayley/query.Session
的用法示例。
在下文中一共展示了Session.Debug方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Repl
func Repl(h *graph.Handle, queryLanguage string, cfg *config.Config) error {
var ses query.Session
switch queryLanguage {
case "sexp":
ses = sexp.NewSession(h.QuadStore)
case "mql":
ses = mql.NewSession(h.QuadStore)
case "gremlin":
fallthrough
default:
ses = gremlin.NewSession(h.QuadStore, cfg.Timeout, true)
}
term, err := terminal(history)
if os.IsNotExist(err) {
fmt.Printf("creating new history file: %q\n", history)
}
defer persist(term, history)
var (
prompt = ps1
code string
)
for {
if len(code) == 0 {
prompt = ps1
} else {
prompt = ps2
}
line, err := term.Prompt(prompt)
if err != nil {
if err == io.EOF {
fmt.Println()
return nil
}
return err
}
term.AppendHistory(line)
line = strings.TrimSpace(line)
if len(line) == 0 || line[0] == '#' {
continue
}
if code == "" {
cmd, args := splitLine(line)
switch cmd {
case ":debug":
args = strings.TrimSpace(args)
var debug bool
switch args {
case "t":
debug = true
case "f":
// Do nothing.
default:
debug, err = strconv.ParseBool(args)
if err != nil {
fmt.Printf("Error: cannot parse %q as a valid boolean - acceptable values: 't'|'true' or 'f'|'false'\n", args)
continue
}
}
ses.Debug(debug)
fmt.Printf("Debug set to %t\n", debug)
continue
case ":a":
quad, err := cquads.Parse(args)
if err != nil {
fmt.Printf("Error: not a valid quad: %v\n", err)
continue
}
h.QuadWriter.WriteQuad(quad)
continue
case ":d":
quad, err := cquads.Parse(args)
if err != nil {
fmt.Printf("Error: not a valid quad: %v\n", err)
continue
}
err = h.QuadWriter.RemoveQuad(quad)
if err != nil {
fmt.Printf("error deleting: %v\n", err)
}
continue
case "exit":
term.Close()
os.Exit(0)
default:
if cmd[0] == ':' {
fmt.Printf("Unknown command: %q\n", cmd)
continue
//.........這裏部分代碼省略.........