shurcooL / vfsgen

Takes an input http.FileSystem (likely at go generate time) and generates Go code that statically implements it.
MIT License
981 stars 83 forks source link

Feature Request: path to generate file #90

Open yookoala opened 3 years ago

yookoala commented 3 years ago

I am writing a library that has a subpackage, which needs to have assets generated. The folder structure looks like this:

mypackage/
  .air.toml
  cmd/
    example/
      main.go
      resources/
        generate.go
        asset.go
        templates/
          index.go.html
          login.go.html

Here are my constrains:

  1. The asset.go file contains my development http.FileSystem declaration. The generate.go contains the development only main package that generates the code.
  2. I want to generate asset_vfsdata.go in the same folder as asset.go.
  3. I want to use air to live reload asset_vfsdata.go. So ideally I want to run the generate.go command at the root folder.

My problem is this: if I run the generate.go at the root folder (mypackage), the generated go file will be placed directly at root, which fails to achieve (2). I tried adding path to vfsgen.Options.Filename, but it seems to be ignored by vfsgen.

I think the clean to do it is to have a vfsgen.Options that specifies the relative output folder somehow.

dmitshur commented 3 years ago

I tried adding path to vfsgen.Options.Filename, but it seems to be ignored by vfsgen.

That shouldn't be the case. Can you show a snippet that reproduces this behavior?