markbates / pkger

Embed static files in Go binaries (replacement for gobuffalo/packr)
MIT License
1.19k stars 60 forks source link

pkger doesn't work with "go run" when placing the entry in "cmd/..." project format #121

Open dschissler opened 4 years ago

dschissler commented 4 years ago

If I first generate the pkged.go file then running go run cmd/server/main.go will work correctly. However if I don't first generate the file then it will fail. However if I simply move cmd/server/main.go to the project root then it will work correctly without needing to generate anything.

So the current workaround seems to be putting my entry go file in the project root. I think that bug #109 might be referencing a similar traversal issue.

I think that this could be a common blocker bug that makes many people think that the tech just doesn't work correctly. I'm only just learning now. Many guides recommend putting the entry into the cmd folder in this way. So with these skeletons pkger is Dead On Arrival. I don't know what I'm doing so its really crazy to copy over the example code into my project and have it fail.

mlboy commented 4 years ago

your can try "pkger -o cmd/server"

leosunmo commented 4 years ago

I am running in to the same issue. Pre-compiled with pkger it worked fine, but since I have my entrypoint in cmd/myproject/main.go it will not work with files on the filesystem.

To make it more confusing for new users such as myself, pkger list seems to indicate that it will work fine, but doesn't unless you run pkger first.