28 lines
366 B
Go
28 lines
366 B
Go
package db
|
|
|
|
import (
|
|
"context"
|
|
"path/filepath"
|
|
|
|
"github.com/glebarez/sqlite"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
var (
|
|
Default *gorm.DB
|
|
)
|
|
|
|
func Init(ctx context.Context, dataDir string) error {
|
|
var (
|
|
err error
|
|
dbPath = filepath.Join(dataDir, "cluster.db")
|
|
)
|
|
|
|
Default, err = gorm.Open(sqlite.Open(dbPath), &gorm.Config{})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|