diff options
| author | Joel Martin <github@martintribe.org> | 2014-10-09 18:27:47 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-10-09 18:27:47 -0500 |
| commit | ad7e866ea1d4d035d876e58bca681a72099449af (patch) | |
| tree | cbd73a7cda5adc4aba7293231ab0efa3f107edb0 /go/src/step0_repl | |
| parent | d667a1bb2e7294f8722bb31f1e6e8207b971c913 (diff) | |
| download | mal-ad7e866ea1d4d035d876e58bca681a72099449af.tar.gz mal-ad7e866ea1d4d035d876e58bca681a72099449af.zip | |
go: add readline.go that wraps libreadline/libedit
Diffstat (limited to 'go/src/step0_repl')
| -rw-r--r-- | go/src/step0_repl/step0_repl.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/go/src/step0_repl/step0_repl.go b/go/src/step0_repl/step0_repl.go index 1203213..2e4c47c 100644 --- a/go/src/step0_repl/step0_repl.go +++ b/go/src/step0_repl/step0_repl.go @@ -1,12 +1,14 @@ package main import ( - "bufio" "fmt" - "os" "strings" ) +import ( + "readline" +) + // read func READ(str string) string { return str @@ -28,11 +30,9 @@ func rep(str string) string { } func main() { - reader := bufio.NewReader(os.Stdin); // repl loop for { - fmt.Print("user> "); - text, err := reader.ReadString('\n'); + text, err := readline.Readline("user> ") text = strings.TrimRight(text, "\n"); if (err != nil) { return |
