UnmarshalJSONFile parses JSON-encoded data from the file named by filename and stores the result in the value pointed to by v. Internally, Unmarshal uses json.Unmarshal.
(filename string, v any)
| 22 | // and stores the result in the value pointed to by v. Internally, Unmarshal |
| 23 | // uses json.Unmarshal. |
| 24 | func UnmarshalJSONFile(filename string, v any) error { |
| 25 | data, err := ReadFile(filename) |
| 26 | if err != nil { |
| 27 | return err |
| 28 | } |
| 29 | if err := json.Unmarshal(data, v); err != nil { |
| 30 | return fmt.Errorf("%s: unmarshaling error: %w", filename, err) |
| 31 | } |
| 32 | return nil |
| 33 | } |
no test coverage detected