Consider the following:
bb := new(bytes.Buffer)
zw := zip.NewWriter(bb)
w, _ := zw.Create("blah/")
if _, err := w.Write([]byte("Hello, world!")); err == nil {
fmt.Println("unexpected Write success")
}
zw.Close()
A trailing forward-slash indicates intent to encode a directory. The API for Create and CreateHeader returns an io.Writer, which allows a user to write "data" for a directory, which has no sensible meaning. It turns out that the Writer does actually encode the data into the archive, but the various zip readers I tested just ignore the data.
I believe the io.Writer returned by Create and CreateHeader should just return an error.
Consider the following:
A trailing forward-slash indicates intent to encode a directory. The API for
CreateandCreateHeaderreturns anio.Writer, which allows a user to write "data" for a directory, which has no sensible meaning. It turns out that the Writer does actually encode the data into the archive, but the various zip readers I tested just ignore the data.I believe the
io.Writerreturned byCreateandCreateHeadershould just return an error.