remove zero mod fs
This commit is contained in:
parent
4b0a410463
commit
8547458f1d
@ -7,45 +7,15 @@ import (
|
|||||||
"github.com/shurcooL/vfsgen"
|
"github.com/shurcooL/vfsgen"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// zeroModTimeFileSystem is an http.FileSystem wrapper.
|
|
||||||
// It exposes a filesystem exactly like Source, except
|
|
||||||
// all file modification times are changed to zero.
|
|
||||||
// See https://github.com/shurcooL/vfsgen/pull/40#issuecomment-355416103
|
|
||||||
type zeroModTimeFileSystem struct {
|
|
||||||
Source http.FileSystem
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fs zeroModTimeFileSystem) Open(name string) (http.File, error) {
|
|
||||||
f, err := fs.Source.Open(name)
|
|
||||||
return file{f}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
type file struct {
|
|
||||||
http.File
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f file) Stat() (os.FileInfo, error) {
|
|
||||||
fi, err := f.File.Stat()
|
|
||||||
return fileInfo{fi}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
type fileInfo struct {
|
|
||||||
os.FileInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fi fileInfo) ModTime() time.Time { return time.Time{} }
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
err := vfsgen.Generate(zeroModTimeFileSystem{
|
fs := union.New(map[string]http.FileSystem{
|
||||||
Source: union.New(map[string]http.FileSystem{
|
"/templates": http.Dir("templates"),
|
||||||
"/templates": http.Dir("templates"),
|
"/source": http.Dir("source"),
|
||||||
"/source": http.Dir("source"),
|
})
|
||||||
}),
|
|
||||||
}, vfsgen.Options{})
|
err := vfsgen.Generate(fs, vfsgen.Options{})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user