GetRootFolder returns the location of this project's root folder. This is useful to locate relative directories, which will often be read from and written to for generation. It is assumed that this will always be called from within an IDE.
()
| 31 | // which will often be read from and written to for generation. It is assumed that this will always be called from |
| 32 | // within an IDE. |
| 33 | func GetRootFolder() (RootFolderLocation, error) { |
| 34 | _, currentFileLocation, _, ok := runtime.Caller(0) |
| 35 | if !ok { |
| 36 | return RootFolderLocation{}, errors.Errorf("failed to fetch the location of the current file") |
| 37 | } |
| 38 | return RootFolderLocation{filepath.Clean(filepath.Join(filepath.Dir(currentFileLocation), "../../.."))}, nil |
| 39 | } |
| 40 | |
| 41 | // MoveRoot returns a new RootFolderLocation that defines the root at the new path. The parameter should be relative to |
| 42 | // the current root. |
no test coverage detected