removing forced paths
This commit is contained in:
parent
8c317fc3b6
commit
006af98328
@ -7,9 +7,3 @@ func WithFile(name string) Option {
|
||||
d.file = name
|
||||
}
|
||||
}
|
||||
|
||||
func WithPath(path string) Option {
|
||||
return func(d *database) {
|
||||
d.path = path
|
||||
}
|
||||
}
|
||||
|
10
sqlite.go
10
sqlite.go
@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
_ "github.com/ncruces/go-sqlite3/driver"
|
||||
@ -13,7 +12,6 @@ import (
|
||||
|
||||
type database struct {
|
||||
file string
|
||||
path string
|
||||
sqlite *sqlx.DB
|
||||
}
|
||||
|
||||
@ -26,23 +24,17 @@ type Database interface {
|
||||
}
|
||||
|
||||
func New(opts ...Option) (Database, error) {
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defaultFile := "lite-db"
|
||||
|
||||
db := &database{
|
||||
file: defaultFile,
|
||||
path: home,
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(db)
|
||||
}
|
||||
|
||||
slite, err := sqlx.Open("sqlite3", fmt.Sprintf("file:%s/%s", db.path, db.file))
|
||||
slite, err := sqlx.Open("sqlite3", fmt.Sprintf("file:%s", db.file))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user