Skip to content

archive/zip: change Writer.Comment field to SetComment method #22737

@rsc

Description

@rsc

CL 59310 added the ability to set the central directory comment in zip.Writer. By analogy with Reader, it added a new Comment string field to writer that callers who care must set before calling Close. It doesn't seem right to me that this is the very first exported field in the Writer struct, and it doesn't seem to match the rest of the operation-based writing API. For example we do not write files by setting an exported Files []struct{FileInfo; io.Reader} in the Writer and then calling Close. I think it would be more in keeping with the rest of Writer's API to instead make setting the comment an explicit method SetComment(string) and leave Writer with no unexported fields.

/cc @dsnet

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions