Virtual File Systems with read-write support in Go. Zero external dependencies.
This package is extracted from rainycape/vfs and maintained as github.com/soulteary/vfs-kit for use across soulteary projects (e.g. apt-proxy).
go get github.com/soulteary/vfs-kitFor a specific version (after tagging):
go get github.com/soulteary/vfs-kit@v0.1.0See package documentation for API details. Example:
import "github.com/soulteary/vfs-kit"
fs := vfs.Memory()
vfs.WriteFile(fs, "hello.txt", []byte("hello"), 0644)
data, _ := vfs.ReadFile(fs, "hello.txt")Optional: set vfs.LogCloseError to log file-close errors (e.g. from a finalizer):
vfs.LogCloseError = func(err error) { log.Printf("vfs close error: %v", err) }| Function / Type | Description |
|---|---|
Memory() |
In-memory VFS |
FS(root) |
On-disk VFS at root |
TmpFS(prefix) |
Temporary on-disk VFS |
Chroot(root, fs) |
VFS with a different root |
ReadOnly(fs) |
Read-only wrapper |
AsReadOnlyFS(v) |
io/fs.FS adapter for read-only use |
MkdirAll, ReadFile, WriteFile, Walk, IsNotExist |
Shorthand utilities |
Mozilla Public License Version 2.0. See LICENSE.