markbates / pkger

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

Allow the user to exclude folder paths #108

Open A1Liu opened 4 years ago

A1Liu commented 4 years ago

This PR allows the user to use the -exclude flag to exclude directories.

cornelk commented 4 years ago

@markbates any chance to get this merged?

markbates commented 4 years ago

Can you add tests please?

A1Liu commented 4 years ago

I'm not sure how to test this; could you help walk me through the process?

jankaszel commented 4 years ago

I've worked on a very similar feature as @A1Liu did and added tests—my proposed API change is a bit different, though, as I would recommend against mutating defaultIgnoredFolders. The API will replace the elegant variadic includes parameter, but I couldn't imagine something else: https://github.com/falafeljan/pkger/blob/f3870921de210862673b62a9a50747a8fd43db66/parser/parser.go#L35-L44

The test looks like this: https://github.com/falafeljan/pkger/blob/f3870921de210862673b62a9a50747a8fd43db66/parser/parser_test.go#L74-L100

Tests fail though, as they do on the main branch atm. @markbates to me it occurs that there is a bug in pkging/pkgtest that will somehow keep references to the first directory created by pkgtest.NewRef() for subsequent tests. As the first directory will be deleted after the first test passed, subsequent tests will fail due to the missing directory. Didn't find a solution for that bug, but if you comment out line 26 in the above parser_test.go, tests for the excludes argument will pass.

jankaszel commented 4 years ago

@A1Liu do you intend to update your PR or shall I open my own one?

A1Liu commented 4 years ago

Go for it dude