@@ -49,5 +49,45 @@ func Stream(dst io.Writer, src io.Reader) (int64, error) {
49
49
* bptr = b
50
50
Recycle (bptr )
51
51
}()
52
- return io .CopyBuffer (dst , src , b )
52
+ return io .CopyBuffer (
53
+ writerNoReadFrom {Writer : dst },
54
+ readerNoWriteTo {Reader : src },
55
+ b ,
56
+ )
57
+ }
58
+
59
+ // from: go-review.googlesource.com/c/go/+/472475/20/src/net/net.go
60
+
61
+ // noReadFrom can be embedded alongside another type to
62
+ // hide the ReadFrom method of that other type.
63
+ type noReadFrom struct {}
64
+
65
+ // ReadFrom hides another ReadFrom method.
66
+ // It should never be called.
67
+ func (noReadFrom ) ReadFrom (io.Reader ) (int64 , error ) {
68
+ panic ("noReadFrom: hidden func; should not be called" )
69
+ }
70
+
71
+ // noWriteTo can be embedded alongside another type to
72
+ // hide the WriterTo method of that other type.
73
+ type noWriteTo struct {}
74
+
75
+ func (noWriteTo ) WriteTo (io.Writer ) (int64 , error ) {
76
+ panic ("noWriteTo: hidden func; should not be called" )
77
+ }
78
+
79
+ // writerNoReadFrom implements all the methods of io.Writer other
80
+ // than ReadFrom. This is used to permit ReadFrom to call io.Copy
81
+ // without leading to a recursive call to ReadFrom.
82
+ type writerNoReadFrom struct {
83
+ noReadFrom
84
+ io.Writer
85
+ }
86
+
87
+ // readerNoWriteTo implements all the methods of io.Reader other
88
+ // than WriteTo. This is used to permit WriteTo to call io.Copy
89
+ // without leading to a recursive call to WriteTo.
90
+ type readerNoWriteTo struct {
91
+ noWriteTo
92
+ io.Reader
53
93
}
0 commit comments