-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change name of output file assets_vfsdata.go
?
#81
Comments
Thanks for the report. For reference, the API of package // Filename of the generated Go code output (including extension).
// If left empty, it defaults to "{{toLower .VariableName}}_vfsdata.go".
Filename string The My goal is to keep the Do you think it would help if we changed the log message that |
Yes, that would satisfy my need perfectly. Perhaps from where it is run or from where it finds go.mod (i.e. the canonical import path) |
I've looked at the source code of Perhaps it's be better to rely on |
I appreciate that it prints out that it is building, but I don't disagree about making the output quiet to be consistent with other tools. I'd like it to have a |
By digging through the code you referenced I was able to find that if I change the name of the variable from
// +build !dev
//go:generate go run -mod vendor github.com/shurcooL/vfsgen/cmd/vfsgendev -source="github.com/example/my-project/my-module/admin".AdminFS
package admin
// +build dev
package admin
import "net/http"
var AdminFS http.FileSystem = http.Dir("assets")
<h1>Hello, Admin!</h1> Of course, naming it |
I can't have two |
Writiting to the stdout unconditionally is noisy and inflexible. The caller is in a better position to decide if anything should be printed to stdout, and it can already do that. So remove the uncoditional write from the Generate function. Don't add anything to vfsgendev, keeping it quiet when everything is successful. This is consistent with various Go code generators like stringer, and testing it out over the last few weeks did not make me feel like something is missing. It's also more consistent with the philosophy for Unix and Plan 9 tools, where it's nice to be quiet when all goes as planned. For #81.
Update: Solution
Change the name of the
http.FileSystem
-typed variable and the name of the output file will change accordingly:From:
To:
The
go generate
comment must also be updated accordingly://go:generate go run -mod vendor github.com/shurcooL/vfsgen/cmd/vfsgendev -source="github.com/example/my-project/my-module/admin".AdminFS
Can the output file name be changed?
When I run
go generate -mod=vendor ./...
I get a list like this:I'd much prefer to be able to change the name of
assets_vfsdata.go
to be more relevant, something like:admin_vfsdata.go
user_vfsdata.go
Being able to specify the filename would make it easier to visually verify that I did run the command that I though I ran.
For example, sometimes I want to build with the admin UI baked-in, but the dev version of the user UI, etc, so it would just be nice to have the feedback match what's actually happening.
Looking at the help, it does not appear to have an option to specify the output.
Changing the folder name from
assets
toadmin
also does not cause any change.For reference
Here's an example of the structure of my project:
admin/admin.go
:admin/admin_dev.go
:admin/admin/index.html
:tools/tools.go
:The text was updated successfully, but these errors were encountered: