Added the write method to the Instance object so that it can be passed around as a io.Writer object.

This commit is contained in:
Kris Watts 2015-09-23 21:22:26 -06:00
parent 8fcf9da96c
commit 800fa3d2b8
2 changed files with 8 additions and 1 deletions

View File

@ -1,12 +1,13 @@
package main package main
import ( import (
"fmt"
"io" "io"
"log" "log"
"strconv" "strconv"
"time" "time"
"github.com/chzyer/readline" "github.com/traetox/readline"
) )
func usage(w io.Writer) { func usage(w io.Writer) {
@ -43,6 +44,8 @@ func main() {
}() }()
case "bye": case "bye":
goto exit goto exit
case "write":
fmt.Fprintf(l, "look, i am writer too\n")
case "": case "":
default: default:
log.Println("you said:", strconv.Quote(line)) log.Println("you said:", strconv.Quote(line))

View File

@ -44,3 +44,7 @@ func (i *Instance) Close() error {
i.o.Close() i.o.Close()
return i.t.Close() return i.t.Close()
} }
func (i *Instance) Write(b []byte) (int, error) {
return i.o.Stderr().Write(b)
}