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

ModTime option #58

Closed beyang closed 6 years ago

beyang commented 6 years ago

This adds a ModTime field to the Options struct, which lets the caller specify a modification time for all generated files. As the docstring states, this is useful in cases where the generated VFS file should change only if the actual file contents (ignoring modification time).

A concrete case is when the generated file is committed to a git repository and there is a CI job that runs go generate and verifies that git diff is empty. Prior to this change the CI job would always fail, because it would generate a VFS file with modification times inherited from the CI filesystem, resulting in a non-zero diff.

dmitshur commented 6 years ago

Thanks for the PR, but please see https://github.com/shurcooL/vfsgen/pull/40#issuecomment-355416103.

There is an open issue #31 to improve this situation, since this is a common feature request (e.g., there was yet another similar PR #54 recently).