twpayne/go-vfs là một trong những repo phía máy chủ mà TopGit theo dõi, hiện có 87 sao, viết chủ yếu bằng Go. Package vfs provides an abstraction of the os and io packages that is easy to test.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Package vfs provides an abstraction of the os and io packages that is easy
to test.
Key features
File system abstraction layer for commonly-used os and io functions from
the standard library.
Powerful and easy-to-use declarative testing framework, vfst. You declare
the desired state of the filesystem after your code has run, and vfst tests
that the filesystem matches that state. For a quick tour of vfst's features,
see the examples in the
documentation.
Compatibility with
github.com/spf13/afero and
github.com/src-d/go-billy.
To use vfs, you write your code to use the FS interface, and then use
vfst to test it.
vfs also provides functions MkdirAll (equivalent to os.MkdirAll),
Contains (an improved filepath.HasPrefix), and Walk (equivalent to
filepath.Walk) that operate on an FS.
The implementations of FS provided are:
OSFS which calls the underlying os and io functions directly.
PathFS which transforms all paths to provide a poor-man's chroot.
ReadOnlyFS which prevents modification of the underlying FS.
TestFS which assists running tests on a real filesystem but in a temporary
directory that is easily cleaned up. It uses OSFS under the hood.
Example usage:
// writeConfigFile is the function we're going to test. It can make arbitrary
// changes to the filesystem through fileSystem.
func writeConfigFile(fileSystem vfs.FS) error {
return fileSystem.WriteFile("/home/user/app.conf", []byte(`app config`), 0644)
}
// TestWriteConfigFile is our test function.
func TestWriteConfigFile(t *testing.T) {
// Create and populate an temporary directory with a home directory.
fileSystem, cleanup, err := vfst.NewTestFS(map[string]any{
"/home/user/.bashrc": "# contents of user's .bashrc\n",
})
// Check that the directory was populated successfully.
if err != nil {
t.Fatalf("vfsTest.NewTestFS(_) == _, _, %v, want _, _, <nil>", err)
}
// Ensure that the temporary directory is removed.
defer cleanup()
// Call the function we want to test.
if err := writeConfigFile(fileSystem); err != nil {
t.Error(err)
}
// Check properties of the filesystem after our function has modified it.
vfst.RunTests(t, fileSystem, "app_conf",
vfst.TestPath("/home/user/app.conf",
vfst.TestModeIsRegular(),
vfst.TestModePerm(0644),
vfst.TestContentsString("app config"),
),
)
}
github.com/spf13/afero compatibility
There is a compatibility shim for
github.com/spf13/afero in
github.com/twpayne/go-vfsafero. This
allows you to use vfst to test existing code that uses
afero.FS. See the
documentation for an example.
github.com/src-d/go-billy compatibility
There is a compatibility shim for
github.com/src-d/go-billy in
github.com/twpayne/go-vfsbilly. This
allows you to use vfst to test existing code that uses
billy.Filesystem.
See the documentation for an
example.
Motivation
vfs was inspired by
github.com/spf13/afero. So, why not use
afero?
afero has several critical bugs in its in-memory mock filesystem
implementation MemMapFs, to the point that it is unusable for non-trivial
test cases. vfs does not attempt to implement an in-memory mock filesystem,
and instead only provides a thin layer around the standard library's os and
io packages, and as such should have fewer bugs.
afero does not support creating or reading symbolic links, and its
LstatIfPossible interface is clumsy to use as it is not part of the
afero.Fs interface. vfs provides out-of-the-box support for symbolic links
with all methods in the FS interface.
afero has been effectively abandoned by its author, and a "friendly fork"
(github.com/absfs/afero) has not seen much
activity. vfs, by providing much less functionality than afero, should be
smaller and easier to maintain.
twpayne/go-vfs thuộc nhóm Backend trên TopGit, cùng 6 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về twpayne/go-vfs ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/twpayne/go-vfs là nguồn chính thức.
twpayne/go-vfs có bao nhiêu sao?
twpayne/go-vfs có 87 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/twpayne/go-vfs. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
twpayne/go-vfs có phải mã nguồn mở không?
Có — twpayne/go-vfs phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/twpayne/go-vfs.
twpayne/go-vfs còn đang phát triển không?
Commit gần nhất trên twpayne/go-vfs là 1.0 năm trước (theo timestamp GitHub). Repo có 6 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
twpayne/go-vfs dùng license gì?
twpayne/go-vfs phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
twpayne/go-vfs là gì?
twpayne/go-vfs (twpayne/go-vfs) là dự án Go trên GitHub. Theo mô tả gốc: Package vfs provides an abstraction of the os and io packages that is easy to test.
twpayne/go-vfs viết bằng ngôn ngữ gì?
twpayne/go-vfs chủ yếu viết bằng Go. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về go-vfs?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về go-vfs.