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

Error: missing package name #10

Closed davidkuridza closed 7 years ago

davidkuridza commented 7 years ago

GenerateOptions struct is defined like this:

type GenerateOptions struct {
    // Name of the package to use. Defaults to 'main'.
    Package string
...

However, doing something like this, fails with a validation error:

files.Generate(os.Stdout, &bindata.GenerateOptions{
    Debug: true,
})

Based on the comment Defaults to 'main'., I assume even if GenerateOptions is present without Package, default value should be set.

Just wanted to clarify it before opening a pull request.

tmthrgd commented 7 years ago

This is indeed a bug. This can very easily be seen as either a mistake in the GenerateOptions documentation or a bug in the (*GenerateOptions).validate method. I'm far more inclined to see this as a documentation mistake. I actively want to discourage people from putting assets into the main package, they should go into an internal subpackage. (This is for various reasons, one of which is faster compilation).

tmthrgd commented 7 years ago

If you wish to open a pull request, I'd suggest it be to correct the documentation.