mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2025-12-12 08:00:04 +01:00
23 lines
320 B
Go
23 lines
320 B
Go
|
|
package main
|
||
|
|
|
||
|
|
import (
|
||
|
|
"io"
|
||
|
|
"net/url"
|
||
|
|
)
|
||
|
|
|
||
|
|
// databaseName returns the database name from a URL
|
||
|
|
func databaseName(u *url.URL) string {
|
||
|
|
name := u.Path
|
||
|
|
if len(name) > 0 && name[:1] == "/" {
|
||
|
|
name = name[1:len(name)]
|
||
|
|
}
|
||
|
|
|
||
|
|
return name
|
||
|
|
}
|
||
|
|
|
||
|
|
func mustClose(c io.Closer) {
|
||
|
|
if err := c.Close(); err != nil {
|
||
|
|
panic(err)
|
||
|
|
}
|
||
|
|
}
|