Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look into doing an FS mixed embed/external #11

Open
kettek opened this issue Jun 30, 2022 · 1 comment
Open

Look into doing an FS mixed embed/external #11

kettek opened this issue Jun 30, 2022 · 1 comment

Comments

@kettek
Copy link
Member

kettek commented Jun 30, 2022

I wrote a small library some time ago that allows one to mix multiple directories into one aggregate "view", with results being an aggregate of the two, with a priority for one over the other. See https://github.com/kettek/go-multipath

However, since I wrote that, an FS interface abstraction was introduced to go. The embed fs functionality we are using adheres to this, so it may be possible to write a v2 of go-multipath that allows us to read from embed as well one or more actual system directories as if they were one.

@kettek
Copy link
Member Author

kettek commented Jul 1, 2022

I committed a v2 of multipath (though I want to rename it multifs). Supporting external files/overrides, would be something like:

import (
  "github.com/kettek/go-multipath/v2"
  "embed"
  "os"
)

//go:embed assets/*
var embedFS embed.FS

var mfs multipath.FS

func InitData() {
  mfs.AddFS(embedFS, multipath.FirstPriority)
  mfs.AddFS(os.DirFS("some_external_directory"), multipath.FirstPriority)
}

The syntax isn't set in stone, as the insert priority doesn't seem that important. Maybe have an AddFS(FS), then InsertFS for specific insertion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant