From 97dbc9e329be43fb7b02016a4ca7bd125f16990b Mon Sep 17 00:00:00 2001 From: Cheney Date: Wed, 23 Sep 2015 13:26:42 +0800 Subject: [PATCH] improve readme --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index e77dcd9..3ec62ea 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,26 @@ A pure go implementation for gnu readline. ![demo](https://raw.githubusercontent.com/chzyer/readline/master/example/demo.gif) +# Usage + +```go +import "github.com/chzyer/readline" + +rl, err := readline.New("> ") +if err != nil { + panic(err) +} +defer rl.Close() + +for { + line, err := rl.Readline() + if err != nil { // io.EOF + break + } + println(line) +} +``` + # Shortcut `Meta`+`B` means press `Esc` and `n` separately.