How to find Rice Box in vendor folder?
Closed this issue · 1 comments
hollowaykeanho commented
Hi,
I've been trying to use FindBox to locate my view folder for some time but no avail. Is there a guide for using Rice in locating the repository's vendor folder?
The repository structure is as follows:
$GOPATH/gitlab.com/holloway/shion-go
|
+-- main.go <-- main file
+-- vendor
|
+-- main
|
+-- views
| |
| +-- root.html.tmpl <-- targeted view file
| +-- partials
| |
| +-- head.html.tmpl <-- targeted view file
| +-- footer.html.tmpl <-- targeted view file
|
+-- controllers
|
+-- main.go <-- FindBox called here
I've tried a few ways already but it won't work. Error complained that it couldn't find the box. These are the path I tried:
- ./vendor
- ./vendor/main
- ./vendor/main/views
- vendor/main/views
- main/views
hollowaykeanho commented
Found. The FindBox fallback to the executed location (https://github.com/GeertJohan/go.rice/blob/master/box.go#L123). This means it is primarily located in vendor/main/controllers/main.go
.
Hence it failed to find vendor/main/views/...
since it starts looking in the controllers
folder. To use rice in this case, one needs to park at the root repository instead and call FindBox there.