tmthrgd / go-bindata

A small utility which generates Go code from any file. Useful for embedding binary data in a Go program. [Obsolete].
https://golang.org/issue/35950
Other
72 stars 4 forks source link

[Proposal] Add way to select exactly which files to include in the result? #7

Closed lestrrat closed 7 years ago

lestrrat commented 7 years ago

I just had a situation where I want to create a new set of assets, but the directory contains generated files and their sources. For example, in the below listing, path/to/files/foo is the only needed file, and path/to/files/foo-source is only required for generating the former file.

path/to/files/foo-source
path/to/files/foo

I want to limit the output to just path/to/files/foo. I would like to propose implementing something like the following

1) define explicit white list

(One file name per line)

go-bindata ... -files list-of-files.txt

2) define black list pattern

(One regular expression per line to match file names against)

go-bindata ... -exclude patterns.txt

3) define white list pattern

(One regular expression per line to match file names against)

go-bindata ... -include patterns.txt
tmthrgd commented 7 years ago

See the README.md regarding changes to the go-bindata command line interface:

"The CLI also remains backwards compatible but is considered deprecated and will not be updated."

All three of these are already possible if you use the package API. All you have to do is provide a Files slice that contains the desired files with a struct that implements the File interface. The second proposal is directly possible using the package API by setting the Ignore field in the FindFilesOptions struct.

The second proposal is already implemented in the CLI with the -ignore flag which skips files that match the given regular expression in files.go. In your case you'd use something like:

go-bindata ... -ignore '.*-source$'

I'm closing this but feel free to reopen if you don't feel that sufficiently addresses your use case.

lestrrat commented 7 years ago

I was going to write

@tmthrgd so go-bindata --help needs updating?

then realized go-bindata in my $PATH was wrong (it was actually the realllllly old one :D) . Sorry for the false alarm!