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) {
|
func New(sourceUrl, databaseUrl string) (*Migrate, error) {
|
||||||
m := newCommon()
|
m := newCommon()
|
||||||
|
|
||||||
sourceName, err := nameFromUrl(sourceUrl)
|
sourceName, err := schemeFromUrl(sourceUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
m.sourceName = sourceName
|
m.sourceName = sourceName
|
||||||
|
|
||||||
databaseName, err := nameFromUrl(databaseUrl)
|
databaseName, err := schemeFromUrl(databaseUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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) {
|
func NewWithDatabaseInstance(sourceUrl string, databaseName string, databaseInstance database.Driver) (*Migrate, error) {
|
||||||
m := newCommon()
|
m := newCommon()
|
||||||
|
|
||||||
sourceName, err := nameFromUrl(sourceUrl)
|
sourceName, err := schemeFromUrl(sourceUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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) {
|
func NewWithSourceInstance(sourceName string, sourceInstance source.Driver, databaseUrl string) (*Migrate, error) {
|
||||||
m := newCommon()
|
m := newCommon()
|
||||||
|
|
||||||
databaseName, err := nameFromUrl(databaseUrl)
|
databaseName, err := schemeFromUrl(databaseUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
11
util.go
11
util.go
|
@ -46,8 +46,8 @@ func suint(n int) uint {
|
||||||
return uint(n)
|
return uint(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
// newSlowReader turns an io.Reader into a slow io.Reader
|
// newSlowReader turns an io.ReadCloser into a slow io.ReadCloser.
|
||||||
// use to simulate a slow internet connection
|
// Use this to simulate a slow internet connection.
|
||||||
func newSlowReader(r io.ReadCloser) io.ReadCloser {
|
func newSlowReader(r io.ReadCloser) io.ReadCloser {
|
||||||
return &slowReader{
|
return &slowReader{
|
||||||
rx: r,
|
rx: r,
|
||||||
|
@ -75,16 +75,17 @@ func (b *slowReader) Close() error {
|
||||||
return b.rx.Close()
|
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)
|
u, err := nurl.Parse(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(u.Scheme) == 0 {
|
if len(u.Scheme) == 0 {
|
||||||
return "", errNoName
|
return "", errNoScheme
|
||||||
}
|
}
|
||||||
|
|
||||||
return u.Scheme, nil
|
return u.Scheme, nil
|
||||||
|
|
Loading…
Reference in New Issue