From ad7e866ea1d4d035d876e58bca681a72099449af Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Thu, 9 Oct 2014 18:27:47 -0500 Subject: go: add readline.go that wraps libreadline/libedit --- go/src/step7_quote/step7_quote.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'go/src/step7_quote') diff --git a/go/src/step7_quote/step7_quote.go b/go/src/step7_quote/step7_quote.go index 4083354..68c2a85 100644 --- a/go/src/step7_quote/step7_quote.go +++ b/go/src/step7_quote/step7_quote.go @@ -1,15 +1,14 @@ package main import ( - "bufio" - //"io" "fmt" - "os" "strings" "errors" + "os" ) import ( + "readline" . "types" "reader" "printer" @@ -220,11 +219,9 @@ func main() { os.Exit(0) } - rdr := bufio.NewReader(os.Stdin); // repl loop for { - fmt.Print("user> "); - text, err := rdr.ReadString('\n'); + text, err := readline.Readline("user> ") text = strings.TrimRight(text, "\n"); if (err != nil) { return -- cgit v1.2.3