...
1
2
3
4
5
6
7 package godoc_vfs
8
9 import (
10 "github.com/golang-migrate/migrate/v4/source"
11 "github.com/golang-migrate/migrate/v4/source/httpfs"
12
13 "golang.org/x/tools/godoc/vfs"
14 vfs_httpfs "golang.org/x/tools/godoc/vfs/httpfs"
15 )
16
17 func init() {
18 source.Register("godoc-vfs", &VFS{})
19 }
20
21
22
23 type VFS struct {
24 httpfs.PartialDriver
25 fs vfs.FileSystem
26 path string
27 }
28
29
30
31
32
33 func (b *VFS) Open(url string) (source.Driver, error) {
34 panic("not implemented")
35 }
36
37
38
39
40
41 func WithInstance(fs vfs.FileSystem, searchPath string) (source.Driver, error) {
42 if searchPath == "" {
43 searchPath = "/"
44 }
45
46 bn := &VFS{
47 fs: fs,
48 path: searchPath,
49 }
50
51 if err := bn.Init(vfs_httpfs.New(fs), searchPath); err != nil {
52 return nil, err
53 }
54
55 return bn, nil
56 }
57
View as plain text