WriteFile write file to path
(filePath, content string)
| 32 | |
| 33 | // WriteFile write file to path |
| 34 | func WriteFile(filePath, content string) error { |
| 35 | file, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE, 0o666) |
| 36 | if err != nil { |
| 37 | return err |
| 38 | } |
| 39 | defer func() { |
| 40 | _ = file.Close() |
| 41 | }() |
| 42 | writer := bufio.NewWriter(file) |
| 43 | if _, err := writer.WriteString(content); err != nil { |
| 44 | return err |
| 45 | } |
| 46 | if err := writer.Flush(); err != nil { |
| 47 | return err |
| 48 | } |
| 49 | return nil |
| 50 | } |
| 51 | |
| 52 | // MoveFile move file to new path |
| 53 | func MoveFile(oldPath, newPath string) error { |
no test coverage detected