The zip package's FileHeader
type, which you linked to, has a .FileInfo()
method which returns an os.FileInfo
type, which itself has an .IsDir()
method.
So chaining that all together, you can tell if the file in the zip archive is a directory with f.FileInfo().IsDir()
.
Example:
package main
import (
"archive/zip"
"fmt"
)
func main() {
// Open a zip archive for reading.
r, err := zip.OpenReader("example.zip")
if err != nil {
fmt.Println(err)
}
defer r.Close()
// Iterate through the files in the archive,
// indicating if it is a directory.
for _, f := range r.File {
fmt.Printf("%s is directory? - %v\n", f.Name, f.FileInfo().IsDir())
}
}