markbates / pkger

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

Fix pkger generating the wrong package name for pkger.go #80

Closed taiyangc closed 4 years ago

taiyangc commented 4 years ago

The issue is that, if pkger.go is created (empty) before the go list -json call it will fail and give the generic directory name instead of the actual package name under the directory. This is fine in most cases, except when the package name differs from the directory name - which is allowed. Then pkger.go will conflict and fail to compile with the rest of *.go under the same directory.

To fix, we simply obtain the real package name before creating the dummy pkger.go file and then pass the name into the file.