-
Notifications
You must be signed in to change notification settings - Fork 5
/
io.go
41 lines (36 loc) · 749 Bytes
/
io.go
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
29
30
31
32
33
34
35
36
37
38
39
40
41
package t
import (
"bufio"
"bytes"
"io"
)
func ParseReader(arg interface{}) *bufio.Reader {
switch arg.(type) {
case bufio.Reader:
var tmp = arg.(bufio.Reader)
return &tmp
case *bufio.Reader:
return arg.(*bufio.Reader)
case io.Reader:
return bufio.NewReader(arg.(io.Reader))
}
return bufio.NewReader(bytes.NewBuffer(ParseBytes(arg)))
}
func ParseWriter(arg interface{}) io.Writer {
switch arg.(type) {
case bufio.Writer:
var tmp = arg.(bufio.Writer)
return &tmp
case *bufio.Writer:
return arg.(*bufio.Writer)
case io.Writer:
return arg.(io.Writer)
}
return nil
}
func (tc TypeContext) Reader() *bufio.Reader {
return ParseReader(tc.val)
}
func (tc TypeContext) Writer() io.Writer {
return ParseWriter(tc.val)
}