Recursively copy Go virtual file systems, such as gobindata, vfsgen, and http.FileSystem.
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
AJ ONeal 86a1bd4bec
update examples section
4 yıl önce
fixtures tested working (for proper implementations) 4 yıl önce
internal/tools tested working (for proper implementations) 4 yıl önce
vendor vendor deps for tests 4 yıl önce
.gitignore tested working (for proper implementations) 4 yıl önce
AUTHORS add LICENSE, AUTHORS, update README 4 yıl önce
LICENSE add LICENSE, AUTHORS, update README 4 yıl önce
README.md update examples section 4 yıl önce
copy.go rename Copy => CopyAll, update docs 4 yıl önce
copy_test.go rename Copy => CopyAll, update docs 4 yıl önce
go.mod tested working (for proper implementations) 4 yıl önce
go.sum tested working (for proper implementations) 4 yıl önce
options.go tested working (for proper implementations) 4 yıl önce
vfs.go tested working (for proper implementations) 4 yıl önce

README.md

vfscopy

Recursively copy a Virtual FileSystem, such as http.FileSystem, to a native file system destination.

Works with any file system that implements http.FileSystem, including vfsgen, fileb0x, gobindata and most others.

GoDoc

See https://pkg.go.dev/git.rootprojects.org/root/vfscopy.

Examples

(Native) File System

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

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

vfsgen (http.FileSystem)

Note: vfsgen does not support symlinks or file permissions.

package main

import (
    "fmt"

    "git.rootprojects.org/root/vfscopy"

    // vfsgen-generated file system
    "git.example.com/org/project/assets"
)

func main() {
    vfs := vfscopy.NewVFS(assets.Assets)

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

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.