mirror of https://github.com/status-im/migrate.git
rename nameFromUrl to schemeFromUrl
This commit is contained in:
parent
46c16bb8f1
commit
8ba71b0754
|
@ -66,13 +66,13 @@ type Migrate struct {
|
|||
func New(sourceUrl, databaseUrl string) (*Migrate, error) {
|
||||
m := newCommon()
|
||||
|
||||
sourceName, err := nameFromUrl(sourceUrl)
|
||||
sourceName, err := schemeFromUrl(sourceUrl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m.sourceName = sourceName
|
||||
|
||||
databaseName, err := nameFromUrl(databaseUrl)
|
||||
databaseName, err := schemeFromUrl(databaseUrl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ func New(sourceUrl, databaseUrl string) (*Migrate, error) {
|
|||
func NewWithDatabaseInstance(sourceUrl string, databaseName string, databaseInstance database.Driver) (*Migrate, error) {
|
||||
m := newCommon()
|
||||
|
||||
sourceName, err := nameFromUrl(sourceUrl)
|
||||
sourceName, err := schemeFromUrl(sourceUrl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ func NewWithDatabaseInstance(sourceUrl string, databaseName string, databaseInst
|
|||
func NewWithSourceInstance(sourceName string, sourceInstance source.Driver, databaseUrl string) (*Migrate, error) {
|
||||
m := newCommon()
|
||||
|
||||
databaseName, err := nameFromUrl(databaseUrl)
|
||||
databaseName, err := schemeFromUrl(databaseUrl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
11
util.go
11
util.go
|
@ -46,8 +46,8 @@ func suint(n int) uint {
|
|||
return uint(n)
|
||||
}
|
||||
|
||||
// newSlowReader turns an io.Reader into a slow io.Reader
|
||||
// use to simulate a slow internet connection
|
||||
// newSlowReader turns an io.ReadCloser into a slow io.ReadCloser.
|
||||
// Use this to simulate a slow internet connection.
|
||||
func newSlowReader(r io.ReadCloser) io.ReadCloser {
|
||||
return &slowReader{
|
||||
rx: r,
|
||||
|
@ -75,16 +75,17 @@ func (b *slowReader) Close() error {
|
|||
return b.rx.Close()
|
||||
}
|
||||
|
||||
var errNoName = fmt.Errorf("no name")
|
||||
var errNoScheme = fmt.Errorf("no scheme")
|
||||
|
||||
func nameFromUrl(url string) (string, error) {
|
||||
// schemeFromUrl returns the scheme from a URL string
|
||||
func schemeFromUrl(url string) (string, error) {
|
||||
u, err := nurl.Parse(url)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if len(u.Scheme) == 0 {
|
||||
return "", errNoName
|
||||
return "", errNoScheme
|
||||
}
|
||||
|
||||
return u.Scheme, nil
|
||||
|
|
Loading…
Reference in New Issue