Skip to content

Commit 0d2a622

Browse files
committed
op-program: Always close both sides of a file channel
Ensures the write channel is closed even if the read channel Close returns an error.
1 parent 33d0e50 commit 0d2a622

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

op-program/io/filechan.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io
22

33
import (
4+
"errors"
45
"io"
56
"os"
67
)
@@ -41,10 +42,7 @@ func (rw *ReadWritePair) Writer() *os.File {
4142
}
4243

4344
func (rw *ReadWritePair) Close() error {
44-
if err := rw.r.Close(); err != nil {
45-
return err
46-
}
47-
return rw.w.Close()
45+
return errors.Join(rw.r.Close(), rw.w.Close())
4846
}
4947

5048
// CreateBidirectionalChannel creates a pair of FileChannels that are connected to each other.

0 commit comments

Comments
 (0)