(w io.Writer, n int64)
| 16 | } |
| 17 | |
| 18 | func NewLimitWriter(w io.Writer, n int64) *LimitWriter { |
| 19 | // If anyone tries this, just make a 0 writer. |
| 20 | if n < 0 { |
| 21 | n = 0 |
| 22 | } |
| 23 | return &LimitWriter{ |
| 24 | Limit: n, |
| 25 | N: 0, |
| 26 | W: w, |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | func (l *LimitWriter) Write(p []byte) (int, error) { |
| 31 | if l.N >= l.Limit { |
no outgoing calls