MCPcopy
hub / github.com/pocketbase/pocketbase / MustSubFS

Function MustSubFS

apis/base.go:82–91  ·  view source on GitHub ↗

MustSubFS returns an [fs.FS] corresponding to the subtree rooted at fsys's dir. This is similar to [fs.Sub] but panics on failure.

(fsys fs.FS, dir string)

Source from the content-addressed store, hash-verified

80//
81// This is similar to [fs.Sub] but panics on failure.
82func MustSubFS(fsys fs.FS, dir string) fs.FS {
83 dir = filepath.ToSlash(filepath.Clean(dir)) // ToSlash in case of Windows path
84
85 sub, err := fs.Sub(fsys, dir)
86 if err != nil {
87 panic(fmt.Errorf("failed to create sub FS: %w", err))
88 }
89
90 return sub
91}
92
93// Static is a handler function to serve static directory content from fsys.
94//

Callers 1

TestMustSubFSFunction · 0.92

Calls 1

SubMethod · 0.80

Tested by 1

TestMustSubFSFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…