Hi, I am doing a file copy in a loop and I want to handle user interrupts such as Ctrl+c. In such an interrupt I need to log the filename of the file being copied (and delete that file from the target). Following is my code snippet (user interrupt handling is not yet implemented),
for _, pFile := range pFiles { srcFilepath := filepath.Join(oPDir, pFile.Name()) dstFilepath := filepath.Join(nPDir, pFile.Name()) if err := utils.CopyFile(srcFilepath, dstFilepath); err != nil { utils.HandleErrorAndExit(fmt.Sprintf(utils.UnableToCopyFileMsg, srcFilepath, dstFilepath), err) } // handle user interrupts } Is it a good idea that I handle the interrupts for every iteration of the loop as above? What is the recommended approach to handle user interrupts in a scenario like this? (I also need to get the file name being copied when the user interrupt is generated) -- Best Regards, Kalpa Welivitigoda +94776509215 http://about.me/callkalpa -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.