golang errror, archive/zip not a valid zip file , Why?

1,811 views
Skip to first unread message

小菜

unread,
Jun 12, 2014, 5:04:30 AM6/12/14
to golan...@googlegroups.com
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?






xxx.zip

Dave Cheney

unread,
Jun 12, 2014, 5:10:52 AM6/12/14
to golan...@googlegroups.com
This is not a zip file

% file xxx.zip
xxx.zip: ERROR: line 5: regexec error 17, (illegal byte sequence)

egon

unread,
Jun 12, 2014, 5:11:08 AM6/12/14
to golan...@googlegroups.com
It's not a plain zip file it's this: https://developer.chrome.com/extensions/crx

+ egon
Reply all
Reply to author
Forward
0 new messages