{"id":13581902,"url":"https://github.com/blang/vfs","last_synced_at":"2025-05-16T13:07:47.459Z","repository":{"id":36538166,"uuid":"40843984","full_name":"blang/vfs","owner":"blang","description":"Virtual filesystem library written in golang","archived":false,"fork":false,"pushed_at":"2024-03-16T18:18:18.000Z","size":57,"stargazers_count":475,"open_issues_count":16,"forks_count":53,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-05-16T13:07:44.650Z","etag":null,"topics":["golang","mocking","vfs","virtual-file-system"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-08-16T22:06:35.000Z","updated_at":"2025-04-16T09:35:05.000Z","dependencies_parsed_at":"2024-06-18T12:37:40.509Z","dependency_job_id":"9d9fb806-1715-4be6-9bcf-ec9645a22977","html_url":"https://github.com/blang/vfs","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blang%2Fvfs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blang%2Fvfs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blang%2Fvfs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blang%2Fvfs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blang","download_url":"https://codeload.github.com/blang/vfs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254535829,"owners_count":22087399,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","mocking","vfs","virtual-file-system"],"created_at":"2024-08-01T15:02:18.611Z","updated_at":"2025-05-16T13:07:47.436Z","avatar_url":"https://github.com/blang.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"vfs for golang [![Build Status](https://travis-ci.org/blang/vfs.svg?branch=master)](https://travis-ci.org/blang/vfs) [![GoDoc](https://godoc.org/github.com/blang/vfs?status.png)](https://godoc.org/github.com/blang/vfs) [![Coverage Status](https://img.shields.io/coveralls/blang/vfs.svg)](https://coveralls.io/r/blang/vfs?branch=master) [![Join the chat at https://gitter.im/blang/vfs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/blang/vfs?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n======\n\nvfs is library to support virtual filesystems. It provides basic abstractions of filesystems and implementations, like `OS` accessing the file system of the underlying OS and `memfs` a full filesystem in-memory.\n\nUsage\n-----\n```bash\n$ go get github.com/blang/vfs\n```\nNote: Always vendor your dependencies or fix on a specific version tag.\n\n```go\nimport github.com/blang/vfs\n```\n\n```go\n// Create a vfs accessing the filesystem of the underlying OS\nvar osfs vfs.Filesystem = vfs.OS()\nosfs.Mkdir(\"/tmp\", 0777)\n\n// Make the filesystem read-only:\nosfs = vfs.ReadOnly(osfs) // Simply wrap filesystems to change its behaviour\n\n// os.O_CREATE will fail and return vfs.ErrReadOnly\n// os.O_RDWR is supported but Write(..) on the file is disabled\nf, _ := osfs.OpenFile(\"/tmp/example.txt\", os.O_RDWR, 0)\n\n// Return vfs.ErrReadOnly\n_, err := f.Write([]byte(\"Write on readonly fs?\"))\nif err != nil {\n    fmt.Errorf(\"Filesystem is read only!\\n\")\n}\n\n// Create a fully writable filesystem in memory\nmfs := memfs.Create()\nmfs.Mkdir(\"/root\", 0777)\n\n// Create a vfs supporting mounts\n// The root fs is accessing the filesystem of the underlying OS\nfs := mountfs.Create(osfs)\n\n// Mount a memfs inside /memfs\n// /memfs may not exist\nfs.Mount(mfs, \"/memfs\")\n\n// This will create /testdir inside the memfs\nfs.Mkdir(\"/memfs/testdir\", 0777)\n\n// This would create /tmp/testdir inside your OS fs\n// But the rootfs `osfs` is read-only\nfs.Mkdir(\"/tmp/testdir\", 0777)\n```\n\nCheck detailed examples below. Also check the [GoDocs](http://godoc.org/github.com/blang/vfs).\n\nWhy should I use this lib?\n-----\n\n- Only Stdlib\n- (Nearly) Fully tested (Coverage \u003e90%)\n- Easy to create your own filesystem\n- Mock a full filesystem for testing (or use included `memfs`)\n- Compose/Wrap Filesystems `ReadOnly(OS())` and write simple Wrappers\n- Many features, see [GoDocs](http://godoc.org/github.com/blang/vfs) and examples below\n\nFeatures and Examples\n-----\n\n- [OS Filesystem support](http://godoc.org/github.com/blang/vfs#example-OsFS)\n- [ReadOnly Wrapper](http://godoc.org/github.com/blang/vfs#example-RoFS)\n- [DummyFS for quick mocking](http://godoc.org/github.com/blang/vfs#example-DummyFS)\n- [MemFS - full in-memory filesystem](http://godoc.org/github.com/blang/vfs/memfs#example-MemFS)\n- [MountFS - support mounts across filesystems](http://godoc.org/github.com/blang/vfs/mountfs#example-MountFS)\n\nCurrent state: ALPHA\n-----\n\nWhile the functionality is quite stable and heavily tested, interfaces are subject to change. \n\n    You need more/less abstraction? Let me know by creating a Issue, thank you.\n\nMotivation\n-----\n\nI simply couldn't find any lib supporting this wide range of variation and adaptability.\n\nContribution\n-----\n\nFeel free to make a pull request. For bigger changes create a issue first to discuss about it.\n\nLicense\n-----\n\nSee [LICENSE](LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblang%2Fvfs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblang%2Fvfs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblang%2Fvfs/lists"}