(p []byte)
| 101 | } |
| 102 | |
| 103 | func (lw *limitedWriter) Write(p []byte) (n int, err error) { |
| 104 | lw.mu.Lock() |
| 105 | defer lw.mu.Unlock() |
| 106 | |
| 107 | if remaining := lw.maxSize - lw.written; remaining > 0 { |
| 108 | toWrite := min(int64(len(p)), remaining) |
| 109 | lw.buf.Write(p[:toWrite]) // bytes.Buffer.Write never errors |
| 110 | lw.written += toWrite |
| 111 | } |
| 112 | return len(p), nil // always report full write |
| 113 | } |
| 114 | |
| 115 | type commandOutput struct { |
| 116 | emit tools.ToolOutputEmitter |