jolheiser
b0b0599fc3
continuous-integration/drone/pr Build is passing
Details
Signed-off-by: jolheiser <john.olheiser@gmail.com> |
||
---|---|---|
_test | ||
.drone.yml | ||
.gitignore | ||
LICENSE | ||
Makefile | ||
README.md | ||
bench.txt | ||
go.mod | ||
overlay.go | ||
overlay_test.go |
README.md
Overlay
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)
}
...
}