Overlay file system
Go to file
jolheiser 57470b0615
Add/change some tests
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2021-02-17 20:33:48 -06:00
_test Initial Commit 2021-02-16 22:57:59 -06:00
.gitignore Initial Commit 2021-02-16 22:57:59 -06:00
LICENSE Initial Commit 2021-02-16 22:57:59 -06:00
Makefile Initial Commit 2021-02-16 22:57:59 -06:00
README.md Initial Commit 2021-02-16 22:57:59 -06:00
bench.txt Initial Commit 2021-02-16 22:57:59 -06:00
go.mod Initial Commit 2021-02-16 22:57:59 -06:00
xtfs.go Initial Commit 2021-02-16 22:57:59 -06:00
xtfs_test.go Add/change some tests 2021-02-17 20:33:48 -06:00

README.md

XTFS

eXTended File System

XTFS is an easy way to implement a file system in such a way that production assets can be overridden by assets on disk.

Usage

package main

import (
	"embed"
	
	"go.jolheiser.com/xtfs"
)

//go:embed assets
var assets embed.FS

func main() {
	xfs, err := xtfs.New("/var/lib/myapp/custom", assets)
	if err != nil {
		panic(err)
    }
    ...
}

If /var/lib/myapp/custom has an assets sub-directory, this implementation works.

However, if /var/lib/myapp/custom matches the assets directory layout, you can use WithSub like so...

package main

import (
	"embed"
	
	"go.jolheiser.com/xtfs"
)

//go:embed assets
var assets embed.FS

func main() {
	xfs, err := xtfs.New("/var/lib/myapp/custom", assets, xtfs.WithSub("assets"))
	if err != nil {
		panic(err)
    }
    ...
}

License

MIT