Files
moxa/interp/realfs.go
2021-09-15 16:22:07 +02:00

22 lines
492 B
Go

package interp
import (
"io/fs"
"os"
)
// realFS complies with the fs.FS interface (go 1.16 onwards)
// We use this rather than os.DirFS as DirFS has no concept of
// what the current working directory is, whereas this simple
// passthru to os.Open knows about working dir automagically.
type realFS struct{}
// Open complies with the fs.FS interface.
func (dir realFS) Open(name string) (fs.File, error) {
f, err := os.Open(name)
if err != nil {
return nil, err
}
return f, nil
}