We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 14f6d3a + 0775323 commit 10a92d0Copy full SHA for 10a92d0
source/file/file.go
@@ -6,12 +6,34 @@ import (
6
"path/filepath"
7
8
"github.com/golang-migrate/migrate/v4/source"
9
+ "github.com/golang-migrate/migrate/v4/source/iofs"
10
)
11
12
func init() {
13
source.Register("file", &File{})
14
}
15
16
+type File struct {
17
+ iofs.PartialDriver
18
+ url string
19
+ path string
20
+}
21
+
22
+func (f *File) Open(url string) (source.Driver, error) {
23
+ p, err := parseURL(url)
24
+ if err != nil {
25
+ return nil, err
26
+ }
27
+ nf := &File{
28
+ url: url,
29
+ path: p,
30
31
+ if err := nf.Init(os.DirFS(p), "."); err != nil {
32
33
34
+ return nf, nil
35
36
37
func parseURL(url string) (string, error) {
38
u, err := nurl.Parse(url)
39
if err != nil {
source/file/file_go115.go
source/file/file_go116.go
0 commit comments