Created
May 17, 2016 08:18
-
-
Save johnsonz/8c76e3f13ed6cf5776d219ddc8644838 to your computer and use it in GitHub Desktop.
go使用7z解压zip文件
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func uncompress(dir string) { | |
err := filepath.Walk(dir, func(path string, file os.FileInfo, err error) error { | |
if file == nil { | |
return nil | |
} | |
if file.IsDir() { | |
return nil | |
} | |
ext := filepath.Ext(path) | |
if ext == ".zip" { | |
cmd := exec.Command("7z", "x", "-aoa", path, "-o"+dir) | |
err := cmd.Run() | |
if err != nil { | |
glog.Errorf("unzip err: %v\n", err) | |
} | |
} | |
return nil | |
}) | |
if err != nil { | |
glog.Errorf("unzip err: %v\n", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment