markbates / pkger

Embed static files in Go binaries (replacement for gobuffalo/packr)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Force reading packaged data in development/test mode?

dmoles opened this issue · comments

I'm trying to write a test to verify that pkged.go matches the contents of my resource directory, which I can then incorporate into a CI pipeline to make sure the generated code committed to the repo is up to date.

Unfortunately, my first naive attempt (using filepath.Walk() to walk the resource directory, and comparing the contents with the results from pkger.Open) made it clear that pkger.Open is just reading the source directory, not the packaged data in pkged.go. (E.g., the test still passes if I add a new file to the resource directory after packaging.) In fact, as far as I can tell, in test, the code in pkged.go (pkger.Apply() etc.) isn't even being executed.

How can I convince pkger to read the packaged data? Or am I fundamentally misunderstanding something here?

See test here, and associated repo (tag pkger-127).