AutoChdir automatically guesses if we need to change the current working directory so that we can find the policies folder
()
| 130 | // AutoChdir automatically guesses if we need to change the current working directory |
| 131 | // so that we can find the policies folder |
| 132 | func AutoChdir() { |
| 133 | var ( |
| 134 | err error |
| 135 | ) |
| 136 | |
| 137 | // Check, if we can find the policies folder |
| 138 | _, err = os.Stat("policies") |
| 139 | if errors.Is(err, os.ErrNotExist) { |
| 140 | // Try again one level deeper |
| 141 | err = os.Chdir("..") |
| 142 | if err != nil { |
| 143 | panic(err) |
| 144 | } |
| 145 | |
| 146 | AutoChdir() |
| 147 | } |
| 148 | } |
no outgoing calls