mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2025-12-11 23:50:04 +01:00
22 lines
322 B
Go
22 lines
322 B
Go
package dbmate
|
|
|
|
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)
|
|
}
|
|
}
|