Commit 0d2a6221 authored by Adrian Sutton's avatar Adrian Sutton

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.
parent 33d0e509
package io
import (
"errors"
"io"
"os"
)
......@@ -41,10 +42,7 @@ func (rw *ReadWritePair) Writer() *os.File {
}
func (rw *ReadWritePair) Close() error {
if err := rw.r.Close(); err != nil {
return err
}
return rw.w.Close()
return errors.Join(rw.r.Close(), rw.w.Close())
}
// CreateBidirectionalChannel creates a pair of FileChannels that are connected to each other.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment