writeMessageCodesFile generates and writes the CODES.md file
(data []byte, destinationFile string)
| 137 | |
| 138 | // writeMessageCodesFile generates and writes the CODES.md file |
| 139 | func writeMessageCodesFile(data []byte, destinationFile string) error { |
| 140 | fh, err := os.Create(destinationFile) |
| 141 | if err != nil { |
| 142 | return fmt.Errorf("failed to open destination file %s (%w)", destinationFile, err) |
| 143 | } |
| 144 | if _, err = fh.Write(data); err != nil { |
| 145 | _ = fh.Close() |
| 146 | return fmt.Errorf("failed to write to destination file %s (%w)", destinationFile, err) |
| 147 | } |
| 148 | if err := fh.Close(); err != nil { |
| 149 | return fmt.Errorf("failed to close destination file %s (%w)", destinationFile, err) |
| 150 | } |
| 151 | return nil |
| 152 | } |
| 153 | |
| 154 | // mustWriteMessageCodesFile is identical to writeMessageCodesFile but panics on error. |
| 155 | func mustWriteMessageCodesFile(data []byte, destinationFile string) { |
no test coverage detected