package main git
import ( github
"archive/zip" code
"fmt" ip
"github.com/axgle/mahonia" it
"io" io
"os" import
) im
func main() { di
File, err := zip.OpenReader("init.zip") co
if err != nil {
fmt.Println(err)
}
defer File.Close()
for _, v := range File.File {
info := v.FileInfo()
if info.IsDir() {
err := os.MkdirAll(mahonia.NewDecoder("gb18030").ConvertString(v.Name), 0644)
if err != nil {
fmt.Println(err)
}
continue
}
srcFile, err := v.Open()
if err != nil {
fmt.Println(err)
continue
}
defer srcFile.Close()
newFile, err := os.Create(mahonia.NewDecoder("gb18030").ConvertString(v.Name))
if err != nil {
fmt.Println(err)
continue
}
io.Copy(newFile, srcFile)
newFile.Close()
}
}