GeertJohan/go.rice

How to find Rice Box in vendor folder?

Closed this issue · 1 comments

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:

  1. ./vendor
  2. ./vendor/main
  3. ./vendor/main/views
  4. vendor/main/views
  5. main/views

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.