CopyFile .
(srcPath, dest string)
| 139 | |
| 140 | // CopyFile . |
| 141 | func CopyFile(srcPath, dest string) error { |
| 142 | fSrc, err := os.Open(srcPath) |
| 143 | if err != nil { |
| 144 | return err |
| 145 | } |
| 146 | defer fSrc.Close() |
| 147 | |
| 148 | CheckExistAndCreate(dest) |
| 149 | destPath := filepath.Join(dest, filepath.Base(srcPath)) |
| 150 | fDest, err := os.OpenFile( |
| 151 | destPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0700) |
| 152 | if err != nil { |
| 153 | return err |
| 154 | } |
| 155 | defer fDest.Close() |
| 156 | |
| 157 | _, err = io.Copy(fDest, fSrc) |
| 158 | if err != nil { |
| 159 | return err |
| 160 | } |
| 161 | |
| 162 | return nil |
| 163 | } |
| 164 | |
| 165 | // Replace uses Regexp to find any matched from `input` with `regexpTerm` |
| 166 | // and replaces them with `replaceTerm` then returns new string. |
no test coverage detected