markbates / pkger

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

fix embed not working with -o #30

Closed nlepage closed 5 years ago

nlepage commented 5 years ago

Hi,

It seems that the embed impl won't work with the new -o option.

Here's a diff of the walk example showing the problem:

diff --git a/examples/walk/pkger/Makefile b/examples/walk/pkger/Makefile
index dd14cf3..a04eaee 100644
--- a/examples/walk/pkger/Makefile
+++ b/examples/walk/pkger/Makefile
@@ -1,5 +1,5 @@
 default:
-       pkger
+       pkger -o pkged
        GOOS=linux go build -v -o example
        docker build -t pkger:example .
        docker run -p 3000:3000 pkger:example
diff --git a/examples/walk/pkger/main.go b/examples/walk/pkger/main.go
index 450d65e..3bb583d 100644
--- a/examples/walk/pkger/main.go
+++ b/examples/walk/pkger/main.go
@@ -8,6 +8,8 @@ import (
        "time"

        "github.com/markbates/pkger"
+
+       _ "app/pkged"
 )

 func main() {
diff --git a/examples/walk/pkger/pkged/package.go b/examples/walk/pkger/pkged/package.go
new file mode 100644
index 0000000..dee4673
--- /dev/null
+++ b/examples/walk/pkger/pkged/package.go
@@ -0,0 +1 @@
+package pkged

Here's what I did:

Go run the example without running pkger works fine.

After running pkger -o pkged doesn't work anymore.

I'm not sure how to write a test for this... but the fix works for the walk example and hopefully for all the other cases.

Thank you for your work.

markbates commented 5 years ago

Thanks! This is in v0.12.1.