all repos — searchix @ 1d518f42e04712c84dfc168cc7a286aabb56e2ed

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: limit file operations using os.Root

Alan Pearce
commit

1d518f42e04712c84dfc168cc7a286aabb56e2ed

parent

dec2c516100350a78f0b7116bc6f9d76325e7760

1 file changed, 20 insertions(+), 1 deletion(-)

changed files
M frontend/dev.gofrontend/dev.go
@@ -3,7 +3,26 @@
package frontend import ( + "io/fs" "os" + "path/filepath" + + "alin.ovh/searchix/internal/file" ) -var Files = os.DirFS("frontend/") +var Files fs.FS + +func init() { + wd, err := os.Getwd() + if err != nil { + panic(err) + } + + //nolint:forbidigo // own source code + root, err := file.OpenRoot(filepath.Join(wd, "frontend")) + if err != nil { + panic(err) + } + + Files = root.FS() +}