Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot close zip.OpenReader #1678

Closed
mark-summerfield opened this issue Apr 8, 2011 · 6 comments
Closed

Cannot close zip.OpenReader #1678

mark-summerfield opened this issue Apr 8, 2011 · 6 comments

Comments

@mark-summerfield
Copy link

I can open a zip file and read the files it contains, but it does not
seem to support the Close() method, so how do I close it when I'm
finished?

    reader, err := zip.OpenReader(filename)
    if err != nil {
        // ...
    }
    //defer reader.Close() -> type *zip.Reader has no field or method Close

Roger Peppe said this might be a bug, hence this report.

cd89452cfea3+ weekly/weekly.2011-04-04
debian testing 64-bit
@gopherbot
Copy link
Contributor

Comment 1 by royger:

I've changed the io.ReaderAt for a custom ReaderAtCloser interface, attached a patch
with the modified files. Haven't submitted it for review because I don't know if this is
the intended solution, but at least allows you to close the files opened with OpenReader.

Attachments:

  1. patch.diff (1612 bytes)

@dchest
Copy link
Contributor

dchest commented Apr 8, 2011

Comment 2:

#1: I think not: the bug is about OpenReader not closing the opened *io.File ZIP file.
You've proposed closing the *zip.File contained inside ZIP, which is unnecessary.

@gopherbot
Copy link
Contributor

Comment 3 by royger:

Yes, messed up files inside the zip with actual openend files. Check this new diff.

Attachments:

  1. patch.diff (1549 bytes)

@dchest
Copy link
Contributor

dchest commented Apr 8, 2011

Comment 4:

I took a different approach by introducing ReadCloser type:
http://golang.org/cl/4372047/

@adg
Copy link
Contributor

adg commented Apr 10, 2011

Comment 5:

Labels changed: added packagebug.

Owner changed to @adg.

Status changed to Accepted.

@adg
Copy link
Contributor

adg commented Apr 10, 2011

Comment 6:

This issue was closed by revision 1b7142d.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc unassigned adg Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants