github.com/dhui/migrate@v3.4.0+incompatible/source/godoc_vfs/vfs_example_test.go (about) 1 package godoc_vfs_test 2 3 import ( 4 "github.com/golang-migrate/migrate" 5 "github.com/golang-migrate/migrate/source/godoc_vfs" 6 "golang.org/x/tools/godoc/vfs/mapfs" 7 ) 8 9 func Example_mapfs() { 10 fs := mapfs.New(map[string]string{ 11 "1_foobar.up.sql": "1 up", 12 "1_foobar.down.sql": "1 down", 13 "3_foobar.up.sql": "3 up", 14 "4_foobar.up.sql": "4 up", 15 "4_foobar.down.sql": "4 down", 16 "5_foobar.down.sql": "5 down", 17 "7_foobar.up.sql": "7 up", 18 "7_foobar.down.sql": "7 down", 19 }) 20 21 d, err := godoc_vfs.WithInstance(fs, "") 22 if err != nil { 23 panic("bad migrations found!") 24 } 25 m, err := migrate.NewWithSourceInstance("godoc-vfs", d, "database://foobar") 26 if err != nil { 27 panic("error creating the migrations") 28 } 29 m.Up() 30 }