goose/osfs.go
Vladimir Stolyarov 3ffdd78efc
Embed support: add 'base' filesystem to discover migrations. (#244)
This needed to use go 1.16 'embed' feature.
By default, migrations discovered from os filesystem.
This can be changed using `SetBaseFS` method.
2021-08-19 09:21:29 -04:00

21 lines
661 B
Go

package goose
import (
"io/fs"
"os"
"path/filepath"
)
// osFS wraps functions working with os filesystem to implement fs.FS interfaces.
type osFS struct{}
func (osFS) Open(name string) (fs.File, error) { return os.Open(filepath.FromSlash(name)) }
func (osFS) ReadDir(name string) ([]fs.DirEntry, error) { return os.ReadDir(filepath.FromSlash(name)) }
func (osFS) Stat(name string) (fs.FileInfo, error) { return os.Stat(filepath.FromSlash(name)) }
func (osFS) ReadFile(name string) ([]byte, error) { return os.ReadFile(filepath.FromSlash(name)) }
func (osFS) Glob(pattern string) ([]string, error) { return filepath.Glob(filepath.FromSlash(pattern)) }