- configuration
This commit is contained in:
abelith committed 2026-08-08 17:40:47 +05:00
1 parent 281d7d76d4
commit a8f164c241
4 files changed
+60 -3

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
package config
import (
"os"
"path/filepath"
)
type Config struct {
DBPath string
}
func NewConfig() (*Config, error) {
dsn, err := getDBPath()
if err != nil {
return nil, err
}
return &Config{DBPath: dsn}, nil
}
func getDBPath() (string, error) {
if dsn := os.Getenv("SPELLBOOK_DB_PATH"); dsn != "" {
return dsn, nil
}
dir, err := os.UserConfigDir()
if err != nil {
return "", err
}
return filepath.Join(dir, "spellbook", "spellbook.db"), nil
}