Description
vfs 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.
vfs for golang alternatives and similar packages
Based on the "Miscellaneous" category.
Alternatively, view vfs for golang alternatives based on common mentions on social networks and blogs.
-
ghorg
Quickly clone or backup an entire org/users repositories into one directory - Supports GitHub, GitLab, Bitbucket, and more ๐๐ฅ -
go-restful-api
An idiomatic Go REST API starter kit (boilerplate) following the SOLID principles and Clean Architecture -
IOC-golang
IOC-golang is a powerful golang dependency injection framework that provides a complete implementation of IoC containers. -
go-starter
An opinionated production-ready SQL-/Swagger-first RESTful JSON API written in Go, highly integrated with VSCode DevContainers by allaboutapps. -
container
A lightweight yet powerful IoC dependency injection container for the Go programming language -
gountries
Gountries provides: Countries (ISO-3166-1), Country Subdivisions(ISO-3166-2), Currencies (ISO 4217), Geo Coordinates(ISO-6709) as well as translations, country borders and other stuff exposed as struct data. -
countries
Countries - ISO-639, ISO-3166 countries codes with subdivisions and names, ISO-4217 currency designators, ITU-T E.164 IDD phone codes, countries capitals, UN M.49 codes, IANA ccTLD countries domains, FIPS, IOC/NOC and FIFA codes, VERY VERY FAST, compatible with Databases/JSON/BSON/GOB/XML/CSV, Emoji countries flags and currencies, Unicode CLDR.
CodeRabbit: AI Code Reviews for Developers

* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of vfs for golang or a related project?
README
vfs for golang

vfs 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.
Usage
$ go get github.com/blang/vfs
Note: Always vendor your dependencies or fix on a specific version tag.
import github.com/blang/vfs
// Create a vfs accessing the filesystem of the underlying OS
var osfs vfs.Filesystem = vfs.OS()
osfs.Mkdir("/tmp", 0777)
// Make the filesystem read-only:
osfs = vfs.ReadOnly(osfs) // Simply wrap filesystems to change its behaviour
// os.O_CREATE will fail and return vfs.ErrReadOnly
// os.O_RDWR is supported but Write(..) on the file is disabled
f, _ := osfs.OpenFile("/tmp/example.txt", os.O_RDWR, 0)
// Return vfs.ErrReadOnly
_, err := f.Write([]byte("Write on readonly fs?"))
if err != nil {
fmt.Errorf("Filesystem is read only!\n")
}
// Create a fully writable filesystem in memory
mfs := memfs.Create()
mfs.Mkdir("/root", 0777)
// Create a vfs supporting mounts
// The root fs is accessing the filesystem of the underlying OS
fs := mountfs.Create(osfs)
// Mount a memfs inside /memfs
// /memfs may not exist
fs.Mount(mfs, "/memfs")
// This will create /testdir inside the memfs
fs.Mkdir("/memfs/testdir", 0777)
// This would create /tmp/testdir inside your OS fs
// But the rootfs `osfs` is read-only
fs.Mkdir("/tmp/testdir", 0777)
Check detailed examples below. Also check the GoDocs.
Why should I use this lib?
- Only Stdlib
- (Nearly) Fully tested (Coverage >90%)
- Easy to create your own filesystem
- Mock a full filesystem for testing (or use included
memfs
) - Compose/Wrap Filesystems
ReadOnly(OS())
and write simple Wrappers - Many features, see GoDocs and examples below
Features and Examples
- OS Filesystem support
- ReadOnly Wrapper
- DummyFS for quick mocking
- MemFS - full in-memory filesystem
- MountFS - support mounts across filesystems
Current state: ALPHA
While the functionality is quite stable and heavily tested, interfaces are subject to change.
You need more/less abstraction? Let me know by creating a Issue, thank you.
Motivation
I simply couldn't find any lib supporting this wide range of variation and adaptability.
Contribution
Feel free to make a pull request. For bigger changes create a issue first to discuss about it.
License
See [LICENSE](LICENSE) file.
*Note that all licence references and agreements mentioned in the vfs for golang README section above
are relevant to that project's source code only.