Recursively copy Go virtual file systems, such as gobindata, vfsgen, and http.FileSystem.
Go to file
AJ ONeal 93990f5db8 add LICENSE, AUTHORS, update README 2020-10-23 15:30:09 -06:00
fixtures tested working (for proper implementations) 2020-10-23 15:21:19 -06:00
internal/tools tested working (for proper implementations) 2020-10-23 15:21:19 -06:00
vendor vendor deps for tests 2020-10-23 15:21:36 -06:00
.gitignore tested working (for proper implementations) 2020-10-23 15:21:19 -06:00
AUTHORS add LICENSE, AUTHORS, update README 2020-10-23 15:30:09 -06:00
LICENSE add LICENSE, AUTHORS, update README 2020-10-23 15:30:09 -06:00
README.md add LICENSE, AUTHORS, update README 2020-10-23 15:30:09 -06:00
copy.go tested working (for proper implementations) 2020-10-23 15:21:19 -06:00
copy_test.go tested working (for proper implementations) 2020-10-23 15:21:19 -06:00
go.mod tested working (for proper implementations) 2020-10-23 15:21:19 -06:00
go.sum tested working (for proper implementations) 2020-10-23 15:21:19 -06:00
options.go tested working (for proper implementations) 2020-10-23 15:21:19 -06:00
vfs.go tested working (for proper implementations) 2020-10-23 15:21:19 -06:00

README.md

vfscopy

Copy a Virtual FileSystem, such as http.FileSystem, recursively to a native file system destination.

Works with any file system that implements http.FileSystem, such as vfsgen, fileb0x, gobindata.

httpfs := http.Dir("/tmp/public/")
vfs := vfscopy.NewVFS(httpfs)

if err := Copy(vfs, ".", "/tmp/dst/"); nil != err {
    fmt.Fprintf(os.Stderr, "couldn't copy vfs: %v\n", err)
}

Test

# Generate the test virtual file system
go generate ./...

# Run the tests
go test ./...

License

The MIT License (MIT)

We used the recursive native file system copy implementation at https://github.com/otiai10/copy as a starting point and added virtual file system support.