23 lines
311 B
Go
23 lines
311 B
Go
|
package stdinprompt_test
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"fmt"
|
||
|
"os"
|
||
|
|
||
|
"src.lwithers.me.uk/go/stdinprompt"
|
||
|
)
|
||
|
|
||
|
func ExampleNew() {
|
||
|
q := make([]byte, 4096)
|
||
|
in := stdinprompt.New()
|
||
|
for {
|
||
|
n, err := in.Read(q)
|
||
|
if err != nil {
|
||
|
fmt.Fprintln(os.Stderr, err)
|
||
|
os.Exit(1)
|
||
|
}
|
||
|
os.Stdout.Write(bytes.ToUpper(q[:n]))
|
||
|
}
|
||
|
}
|