readFile binds the content of a file to a string variable. It populates an error if it fails to read the file content.
(path, filename string, target *string)
| 671 | // readFile binds the content of a file to a string variable. It populates an |
| 672 | // error if it fails to read the file content. |
| 673 | func (form *FormData) readFile(path, filename string, target *string) *FormData { |
| 674 | b, err := os.ReadFile(path) |
| 675 | if err != nil { |
| 676 | form.append( |
| 677 | fmt.Errorf("form file '%s' is invalid (%w)", filename, err), |
| 678 | ) |
| 679 | |
| 680 | return form |
| 681 | } |
| 682 | |
| 683 | *target = string(b) |
| 684 | |
| 685 | return form |
| 686 | } |
no test coverage detected