markbates / pkger

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

pkger fails if a project contains a .go directory #76

Closed ghouscht closed 4 years ago

ghouscht commented 4 years ago

Hi, pkger fails if a project contains a folder named .go - I know probably not the best name, better don't ask about the details 😄

2020/03/04 13:57:55 read /work/go/patty/.go: is a directory: ParseDir failed /work/go/patty: /work/go/patty

The call to the go parser (in parser.go#L113) is called without a filter and the docs say:

ParseDir calls ParseFile for all files with names ending in ".go" in the directory specified by path and returns a map of package name -> package AST with all the packages found.

so a directory named .go is included and later passed to ParseFile (parser.go#L65) which returns the error. Solution is simple though, just call ParseDirwith a filter to exclude directories.