NewDocument creates a document from the filepath. The root is typically the root of the exercise, and path is the absolute path to the file.
(root, path string)
| 12 | // The root is typically the root of the exercise, and |
| 13 | // path is the absolute path to the file. |
| 14 | func NewDocument(root, path string) (Document, error) { |
| 15 | path, err := filepath.Rel(root, path) |
| 16 | if err != nil { |
| 17 | return Document{}, err |
| 18 | } |
| 19 | return Document{ |
| 20 | Root: root, |
| 21 | RelativePath: path, |
| 22 | }, nil |
| 23 | } |
| 24 | |
| 25 | // Filepath is the absolute path to the document on the filesystem. |
| 26 | func (doc Document) Filepath() string { |
no outgoing calls