Home

overlay @main - 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--
1.0 kB
README.md
-rw-r--r--
41 B
go.mod
-rw-r--r--
2.2 kB
overlay.go
-rw-r--r--
2.4 kB
overlay_test.go

Overlay

Go Reference

Overlay File System

Overlay 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/overlay"
)

//go:embed assets
var assets embed.FS

func main() {
	ofs, err := overlay.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/overlay"
)

//go:embed assets
var assets embed.FS

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

License

MIT