godog/internal/storage/fs.go
Tighearnán Carroll 6ce2b8696b
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>
2023-03-27 21:52:51 +02:00

21 строка
318 Б
Go

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)
}