Home

overlay @main - refs - log -
-
https://git.jolheiser.com/overlay.git
Overlay FS
overlay / README.md
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Overlay

[![Go Reference](https://pkg.go.dev/badge/go.jolheiser.com/overlay.svg)](https://pkg.go.dev/go.jolheiser.com/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

```go
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...

```go
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](LICENSE)