Home

overlay @57470b06150e26cbb852802bcc29e85badb9baa3 - refs - log -
-
https://git.jolheiser.com/overlay.git
Overlay FS
drwxrwxrwx
63 B
_test/
-rw-r--r--
18 B
.gitignore
-rw-r--r--
1.1 kB
LICENSE
-rw-r--r--
176 B
Makefile
-rw-r--r--
861 B
README.md
-rw-r--r--
333 B
bench.txt
-rw-r--r--
38 B
go.mod
-rw-r--r--
1.5 kB
xtfs.go
-rw-r--r--
1.6 kB
xtfs_test.go

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