Skip to content
This repository was archived by the owner on Jul 7, 2020. It is now read-only.

reader: add Close method #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Shugyousha
Copy link

We use the library in a server and don't want to have file descriptors leaking.

The way I implemented it now changes the API so it may not be welcome. We could instead add a NewReaderAtCloser() (*ReaderAtCloser, error) function. The ReaderAtCloser could embed a Reader and thus offer the same functionality without changing the API for existing users.

The Close method closes the ReaderAtCloser that underlies the Reader.
@@ -75,9 +75,15 @@ import (
"strconv"
)

// ReaderAtCloser combines the io.ReaderAt and io.Closer interfaces.
type ReaderAtCloser interface {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest naming this type ReadAtCloser. That would be consistent with how io.Reader and io.ReadCloser are combined in io.ReadCloser instead of io.ReaderCloser. There are more examples for this in io.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants