44 lines
968 B
Markdown
Raw Normal View History

# go_bindata
## Usage
2017-04-21 13:29:13 -07:00
### Read bindata with NewWithSourceInstance
2017-04-21 13:29:13 -07:00
```shell
go get -u github.com/jteeuwen/go-bindata/...
cd examples/migrations && go-bindata -pkg migrations .
```
2017-04-21 13:29:13 -07:00
```go
import (
"github.com/golang-migrate/migrate"
"github.com/golang-migrate/migrate/source/go_bindata"
"github.com/golang-migrate/migrate/source/go_bindata/examples/migrations"
)
func main() {
2017-04-21 13:29:13 -07:00
// wrap assets into Resource
s := bindata.Resource(migrations.AssetNames(),
func(name string) ([]byte, error) {
return migrations.Asset(name)
})
2017-07-03 15:45:57 +02:00
d, err := bindata.WithInstance(s)
m, err := migrate.NewWithSourceInstance("go-bindata", d, "database://foobar")
m.Up() // run your migrations and handle the errors above of course
}
```
2017-04-21 13:29:13 -07:00
### Read bindata with URL (todo)
This will restore the assets in a tmp directory and then
2017-04-21 13:29:13 -07:00
proxy to source/file. go-bindata must be in your `$PATH`.
2017-04-21 13:29:13 -07:00
```
migrate -source go-bindata://examples/migrations/bindata.go
2017-04-21 13:29:13 -07:00
```