Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with paths #164

Open
precisionpete opened this issue Feb 8, 2021 · 1 comment
Open

Problems with paths #164

precisionpete opened this issue Feb 8, 2021 · 1 comment

Comments

@precisionpete
Copy link

precisionpete commented Feb 8, 2021

It's a great tool. But I'm struggling a bit...

rice embed-go does not seem to find code is subfolders. I'm building a small web app using templates and some static files.

Main.go is in the root and my handlers are all in a handlers folder. If I run rice embed-go, it finds any resources I reference in the main.go just fine. If I scan the rice-box.go, I have lots of stuff there. And it all works as expected.

But, I cannot get it to find files I reference from my handlers in the subfolder. i.e. if I call tBox, err := rice.FindBox("templates") in a handler, they do not show up in the rice-box.go file. No errors until I execute the binary on a separate system. Then it blows up on a nil pointer.

To get it to work, I have to construct the Box twice. Once in the handler so I can use it. And once in the main.go so the embedded can find it. And in the handler, I have to call it with a relative "../name" to find it from the handlers folder. Unless I have it swapped in a separate func when suddenly it doesn't need the relative path anymore. But the func is also defined in the handlers folder?.?

I can get it to work. But I really would like to understand why it's like this. It seems very strange.

@said-saifi
Copy link

@precisionpete
Does not the below fix your issue?

rice embed-go -i ./ -i ./handlers

Explanation:

-i, --import-path= Import path(s) to use. Using PWD when left empty. Specify multiple times for more import paths to append

./ is for your main.go and ./handlers from your handlers package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants