aboutsummaryrefslogtreecommitdiffhomepage
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go32
1 files changed, 14 insertions, 18 deletions
diff --git a/main.go b/main.go
index 92b7713c3..455a33515 100644
--- a/main.go
+++ b/main.go
@@ -1641,15 +1641,13 @@ func (out *testStdout) Write(data []byte) (int, error) {
defer buf.mu.Unlock()
// Append the output.
- var prev []byte
- if len(buf.output) > 0 && !buf.output[len(buf.output)-1].stderr {
- prev = buf.output[len(buf.output)-1].data
- buf.output = buf.output[:len(buf.output)-1]
- }
- buf.output = append(buf.output, outputEntry{
- stderr: false,
- data: append(prev, data...),
- })
+ if len(buf.output) == 0 || buf.output[len(buf.output)-1].stderr {
+ buf.output = append(buf.output, outputEntry{
+ stderr: false,
+ })
+ }
+ last := &buf.output[len(buf.output)-1]
+ last.data = append(last.data, data...)
return len(data), nil
}
@@ -1674,15 +1672,13 @@ func (out *testStderr) Write(data []byte) (int, error) {
defer buf.mu.Unlock()
// Append the output.
- var prev []byte
- if len(buf.output) > 0 && buf.output[len(buf.output)-1].stderr {
- prev = buf.output[len(buf.output)-1].data
- buf.output = buf.output[:len(buf.output)-1]
- }
- buf.output = append(buf.output, outputEntry{
- stderr: true,
- data: append(prev, data...),
- })
+ if len(buf.output) == 0 || !buf.output[len(buf.output)-1].stderr {
+ buf.output = append(buf.output, outputEntry{
+ stderr: true,
+ })
+ }
+ last := &buf.output[len(buf.output)-1]
+ last.data = append(last.data, data...)
return len(data), nil
}