func addFileToZip(filepath string, filename string, zipw *zip.Writer) error {
	file, err := os.Open(filepath)

	if err != nil {
		return fmt.Errorf("Error opening file %s: %s", filepath, err)
	}
	defer file.Close()

	wr, err := zipw.Create(filename)
	if err != nil {
		return fmt.Errorf("Error adding file; '%s' to zip : %s", filename, err)
	}

	if _, err := io.Copy(wr, file); err != nil {
		return fmt.Errorf("Error writing %s to zip: %s", filename, err)
	}

	return nil
}
// Adds a new file to the ZIP
Adds a new file to the ZIP
// Adds a new file to the ZIP
func addFileToZip(filepath string, filename string, zipw *zip.Writer) error {
	file, err := os.Open(filepath)
	if err != nil {
		return fmt.Errorf("Error opening file %s: %s", filepath, err)
	}
	defer file.Close()
	wr, err := zipw.Create(filename)
	if err != nil {
		return fmt.Errorf("Error adding file; '%s' to zip : %s", filename, err)
	}
	if _, err := io.Copy(wr, file); err != nil {
		return fmt.Errorf("Error writing %s to zip: %s", filename, err)
	}
	return nil
}
func addFileToZip ( filepath string , filename string , zipw * zip . Writer ) error { file , err := os . Open ( filepath ) if err != nil { return fmt . Errorf ( " " , filepath , err ) } defer file . Close ( ) wr , err := zipw . Create ( filename ) if err != nil { return fmt . Errorf ( " " , filename , err ) } if _ , err := io . Copy ( wr , file ) ; err != nil { return fmt . Errorf ( " " , filename , err ) } return nil }
Adds a new file to the ZIP
Adds a new file to the ZIP