CopyFile the source file contents to destination file attributes wont be copied and an existing file will be overwritten.
(src, dst string)
| 45 | // CopyFile the source file contents to destination |
| 46 | // file attributes wont be copied and an existing file will be overwritten. |
| 47 | func CopyFile(src, dst string) { |
| 48 | in, err := os.Open(src) |
| 49 | if err != nil { |
| 50 | log.Fatal(err) |
| 51 | } |
| 52 | |
| 53 | defer func() { |
| 54 | if errClose := in.Close(); errClose != nil { |
| 55 | fmt.Println(errClose) |
| 56 | } |
| 57 | }() |
| 58 | |
| 59 | out, err := os.Create(dst) |
| 60 | if err != nil { |
| 61 | log.Fatal(err) |
| 62 | } |
| 63 | |
| 64 | _, err = io.Copy(out, in) |
| 65 | if err != nil { |
| 66 | log.Fatal(err) |
| 67 | } |
| 68 | |
| 69 | err = out.Close() |
| 70 | if err != nil { |
| 71 | log.Fatal(err) |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // Confirm displays a prompt message to the terminal and returns a bool indicating the user decision. |
| 76 | func Confirm(s string) bool { |