Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
fs.FS
abstraction for filesystem (#550)
* compiles * mock fs in tests * fix parser tests * fix run.go * rename FeatureFS to FS * fix docs typos * remove debug log * add os.DirFS("./") to default options * reword docstring * add fs wrapper * updated readme and changelog * added note * fix changelog * remove ./ gating from defaults * add new storage.FS tests * increase coverage of parser.parsePath * increase coverage of TestSuite.RetrieveFeatures * remove another os.Stat --------- Co-authored-by: Tighearnán Carroll <tighearnan.carroll@gamil.com>
- Loading branch information
1 parent
3bd9e9c
commit 6ce2b86
Showing
11 changed files
with
331 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package storage | ||
|
||
import ( | ||
"io/fs" | ||
"os" | ||
) | ||
|
||
// FS is a wrapper that falls back to `os`. | ||
type FS struct { | ||
FS fs.FS | ||
} | ||
|
||
// Open a file in the provided `fs.FS`. If none provided, | ||
// open via `os.Open` | ||
func (f FS) Open(name string) (fs.File, error) { | ||
if f.FS == nil { | ||
return os.Open(name) | ||
} | ||
|
||
return f.FS.Open(name) | ||
} |
Oops, something went wrong.