package main
import (
"fmt"
"io"
//"net/http"
"os"
"archive/zip"
"log"
)
func main() {
// Open a zip archive for reading.
r, err := zip.OpenReader("xxx.zip")
if err != nil {
log.Fatal(err)
}
defer r.Close()
// Iterate through the files in the archive,
// printing some of their contents.
for _, f := range r.File {
fmt.Printf("Contents of %s:\n", f.Name)
rc, err := f.Open()
if err != nil {
log.Fatal(err)
}
_, err = io.CopyN(os.Stdout, rc, 68)
if err != nil {
log.Fatal(err)
}
rc.Close()
fmt.Println()
}
}
go run t.go
2014/06/12 16:47:41 zip: not a valid zip file
the zip file can open by WinRAR, why can't open by golang?