Skip to content

Change name of output file assets_vfsdata.go? #81

@coolaj86

Description

@coolaj86

Update: Solution

Change the name of the http.FileSystem-typed variable and the name of the output file will change accordingly:

From:

// Creates assets_vfsdata.go
var Assets http.FileSystem = http.Dir("assets")

To:

// Creates adminfs_vfsdata.go
var AdminFS http.FileSystem = http.Dir("assets")

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:

writing assets_vfsdata.go
writing assets_vfsdata.go

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.

go run -mod vendor github.com/shurcooL/vfsgen/cmd/vfsgendev --help

Changing the folder name from assets to admin also does not cause any change.

For reference

Here's an example of the structure of my project:

admin/admin.go:

// +build !dev
//go:generate go run -mod vendor github.com/shurcooL/vfsgen/cmd/vfsgendev -source="github.com/example/my-project/my-module/admin".Assets

package admin

admin/admin_dev.go:

// +build dev

package admin

import "net/http"

var Assets http.FileSystem = http.Dir("admin")

admin/admin/index.html:

<h1>Hello, Admin!</h1>

tools/tools.go:

// +build tools

// tools is a faux package for tracking tooling-related dependencies
package tools

import (
	_ "git.rootprojects.org/root/go-gitver"
	_ "github.com/shurcooL/vfsgen"
	_ "github.com/shurcooL/vfsgen/cmd/vfsgendev"
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions