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

Make the mod time optional #54

Closed jribe closed 6 years ago

jribe commented 6 years ago

Including the file modification time can make output non-reproducible in CI. That makes it difficult to use vfsgen in tandem with a check that runs go:generate and checks that no files changed.

This change adds an opt-out mechanism so that vfsgen's output will always be the same if the file contents have not changed.

dmitshur commented 6 years ago

Hi @jribe, thanks for the PR!

However, it is already possible to make the modify times zero, and it can be done without making direct changes to vfsgen. The way it can be done is with a wrapper http.FileSystem implementation that passes through an underlying filesystem, but overrides the modtime of all files. You can see an example of it implemented at https://github.com/shurcooL/vfsgen/pull/40#issuecomment-355416103.

There is an open issue #31 related to this. I'd like to resolve it by documenting this better, since this is not the first time this came up. I'll close this PR since we shouldn't need to merge it, but thank you again for contributing.

jribe commented 6 years ago

If nothing else, it would be useful to have an implementation of the workaround in the github.com/shurcooL/httpfs family of packages. That workaround is longer than a typical *_generate.go file, so it's non-trivial in context.