go-ini/ini

Append() get file already closed when trying to append a second io.Reader

EdoaLive opened this issue · 1 comments

Version

v1.66.6

Describe the bug

Passing an io.Reader to Append() adds the Reader to the dataSources, but the Reload() closes the Reader after parse (file.go line 296).
Calling Append() a second time will call again Reload() which try to re-parse all dataSources and find the previous io.Reader closed, returning error.

To reproduce

  • Call Append() passing an io.Reader
  • Call Append() again with another source (any?)

Expected behavior

I don't think the Append() method was designed to be called just once, so I think this is an unexpected behavior.
I expected to be able to call Append() many times.

Hmm, how can io.Reader be read more than once? I don't think that's an expected behavior of the interface either. I'm wondering if we should just ignore the EOF error, if the original data source is not a type capable of being re-read (e.g. io.Reader, io.ReadCloser).