func zipMe(filepaths []string, target string, directoryToCut string) error {

	flags := os.O_WRONLY | os.O_CREATE | os.O_TRUNC
	file, err := os.OpenFile(target, flags, 0644)

	if err != nil {
		return fmt.Errorf("Failed to open zip for writing: %s", err)
	}
	defer file.Close()

	zipw := zip.NewWriter(file)
	defer zipw.Close()

	for _, filepath := range filepaths {
		last := strings.LastIndex(filepath, directoryToCut)
		filename := filepath[last:len(filepath)]
		fmt.Print("The filename is " + filename)
		if err := addFileToZip(filepath, filename, zipw); err != nil {
			return fmt.Errorf("Failed to add file %s to zip: %s", filepath, err)
		}
	}
	return nil

}
// Zips all files given to the directory target given.
// target SHOULD EN IN .ZIP and have the full path
// diractoryToCut is the last directory it should remain, otherwise will create the whole path structure of folder from the system
Zips all files given to the directory target given.
target SHOULD EN IN .ZIP and have the full path
diractoryToCut is the last directory it should remain, otherwise will create the whole path structure of folder from the system
// Zips all files given to the directory target given . // target SHOULD EN IN . ZIP and have the full path // diractoryToCut is the last directory it should remain otherwise will create the whole path structure of folder from the system
func zipMe(filepaths []string, target string, directoryToCut string) error {
	flags := os.O_WRONLY | os.O_CREATE | os.O_TRUNC
	file, err := os.OpenFile(target, flags, 0644)
	if err != nil {
		return fmt.Errorf("Failed to open zip for writing: %s", err)
	}
	defer file.Close()
	zipw := zip.NewWriter(file)
	defer zipw.Close()
	for _, filepath := range filepaths {
		last := strings.LastIndex(filepath, directoryToCut)
		filename := filepath[last:len(filepath)]
		fmt.Print("The filename is " + filename)
		if err := addFileToZip(filepath, filename, zipw); err != nil {
			return fmt.Errorf("Failed to add file %s to zip: %s", filepath, err)
		}
	}
	return nil
}
func zipMe ( filepaths [ ] string , target string , directoryToCut string ) error { flags := os . O_WRONLY | os . O_CREATE | os . O_TRUNC file , err := os . OpenFile ( target , flags , 0644 ) if err != nil { return fmt . Errorf ( " " , err ) } defer file . Close ( ) zipw := zip . NewWriter ( file ) defer zipw . Close ( ) for _ , filepath := range filepaths { last := strings . LastIndex ( filepath , directoryToCut ) filename := filepath [ last : len ( filepath ) ] fmt . Print ( " " + filename ) if err := addFileToZip ( filepath , filename , zipw ) ; err != nil { return fmt . Errorf ( " " , filepath , err ) } } return nil }
Zips all files given to the directory target given.
Zips all files given to the directory target given .