Posts

Showing posts with the label zip

zip folder with source and target

zip folder with source and target I use the following code which zip some folder to a given path,the issue that im currently facing is that I need to zip some folder with content into specific target and not in the same directory For example Folder in path like source "/Users/i03434/go/src/zdf/BUILD" "/Users/i03434/go/src/zdf/BUILD" target "/Users/i03434/go/src/zdf/app/info.zip" "/Users/i03434/go/src/zdf/app/info.zip" currently I try to add new path[2] which doesnt helps, any idea how to do it? This is all the code func zipit(params ...string) error { zipfile, err := os.Create(params[1]) if err != nil { return err } defer zipfile.Close() archive := zip.NewWriter(zipfile) defer archive.Close() info, err := os.Stat(params[0]) if err != nil { return err } var baseDir string if info.IsDir(); len(params) > 2 { baseDir = params[2] } else { baseDir = filepath.Base(params[...