bindata

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2022 License: MIT Imports: 5 Imported by: 1

README

go-bindata source

This source reads migrations from a go-bindata embedded binary file.

Usage

To read the embedded data, create a migration source through the WithInstance method and then instantiate morph:

import (
    "github.com/go-morph/morph"
    "github.com/go-morph/morph/sources/go_bindata"
    "github.com/go-morph/morph/sources/go_bindata/testdata"
)

func main() {
    res := bindata.Resource(testdata.AssetNames(), func(name string) ([]byte, error) {
        return testdata.Asset(name)
    })

    src, err := bindata.WithInstance(res)
    if err != nil {
        panic(err)
    }

    // create the morph instance from the source and driver
    m := morph.NewFromConnURL("postgres://...", src, opts)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithInstance

func WithInstance(assetSource *AssetSource) (sources.Source, error)

Types

type AssetFunc

type AssetFunc func(name string) ([]byte, error)

type AssetSource

type AssetSource struct {
	Names     []string
	AssetFunc AssetFunc
}

func Resource

func Resource(names []string, fn AssetFunc) *AssetSource

type Bindata

type Bindata struct {
	// contains filtered or unexported fields
}

func (*Bindata) Close

func (b *Bindata) Close() error

func (*Bindata) Migrations

func (b *Bindata) Migrations() []*models.Migration

func (*Bindata) Open

func (b *Bindata) Open(url string) (sources.Source, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL