Skip to content

Commit

Permalink
fix source/file driver
Browse files Browse the repository at this point in the history
  • Loading branch information
Fontinalis committed Sep 16, 2021
1 parent 14f6d3a commit 0775323
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 64 deletions.
22 changes: 22 additions & 0 deletions source/file/file.go
Expand Up @@ -6,12 +6,34 @@ import (
"path/filepath"

"github.com/golang-migrate/migrate/v4/source"
"github.com/golang-migrate/migrate/v4/source/iofs"
)

func init() {
source.Register("file", &File{})
}

type File struct {
iofs.PartialDriver
url string
path string
}

func (f *File) Open(url string) (source.Driver, error) {
p, err := parseURL(url)
if err != nil {
return nil, err
}
nf := &File{
url: url,
path: p,
}
if err := nf.Init(os.DirFS(p), "."); err != nil {
return nil, err
}
return nf, nil
}

func parseURL(url string) (string, error) {
u, err := nurl.Parse(url)
if err != nil {
Expand Down
32 changes: 0 additions & 32 deletions source/file/file_go115.go

This file was deleted.

32 changes: 0 additions & 32 deletions source/file/file_go116.go

This file was deleted.

0 comments on commit 0775323

Please sign in to comment.