tree: c52c8dc268c34d2902f78d7b62bd7e494515378b [path history] [tgz]
  1. examples/
  2. testdata/
  3. go-bindata.go
  4. go-bindata_test.go
  5. README.md
source/go-bindata/README.md

go-bindata

Usage

Read bindata with NewWithSourceInstance

go get -u github.com/jteeuwen/go-bindata/...
cd examples/migrations && go-bindata -pkg migrations .
import (
  "github.com/mattes/migrate"
  "github.com/mattes/migrate/source/go-bindata"
  "github.com/mattes/migrate/source/go-bindata/examples/migrations"
)

func main() {
  // wrap assets into Resource
  s := bindata.Resource(migrations.AssetNames(),
    func(name string) ([]byte, error) {
      return migrations.Asset(name)
    })
    
  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
}

Read bindata with URL (todo)

This will restore the assets in a tmp directory and then proxy to source/file. go-bindata must be in your $PATH.

migrate -source go-bindata://examples/migrations/bindata.go