NewExerciseMetadata reads exercise metadata from a file in the given directory.
(dir string)
| 30 | |
| 31 | // NewExerciseMetadata reads exercise metadata from a file in the given directory. |
| 32 | func NewExerciseMetadata(dir string) (*ExerciseMetadata, error) { |
| 33 | b, err := os.ReadFile(filepath.Join(dir, metadataFilepath)) |
| 34 | if err != nil { |
| 35 | return nil, err |
| 36 | } |
| 37 | var metadata ExerciseMetadata |
| 38 | if err := json.Unmarshal(b, &metadata); err != nil { |
| 39 | return nil, err |
| 40 | } |
| 41 | metadata.Dir = dir |
| 42 | return &metadata, nil |
| 43 | } |
| 44 | |
| 45 | // Suffix is the serial numeric value appended to an exercise directory. |
| 46 | // This is appended to avoid name conflicts, and does not indicate a particular |
no outgoing calls