-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuffer_test.go
More file actions
28 lines (21 loc) · 791 Bytes
/
buffer_test.go
File metadata and controls
28 lines (21 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package command
import "io"
// readStringer wraps an io.Reader and provides a custom String() method.
type readStringer struct {
io.Reader
string
}
func (r *readStringer) String() string { return r.string }
// namedRW is a string that implements io.ReadWriter and fmt.Stringer.
type namedRW string
func (s namedRW) String() string { return string(s) }
func (namedRW) Read(p []byte) (int, error) { return 0, io.EOF }
func (namedRW) Write(p []byte) (int, error) { return len(p), nil }
// closeTracker tracks whether Close() has been called.
type closeTracker bool
func (*closeTracker) Read(p []byte) (int, error) { return 0, io.EOF }
func (*closeTracker) Write(p []byte) (int, error) { return len(p), nil }
func (c *closeTracker) Close() error {
*c = true
return nil
}