26 lines
390 B
Go
26 lines
390 B
Go
package config
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
)
|
|
|
|
type Config struct {
|
|
BaseDir string
|
|
DBPath string
|
|
}
|
|
|
|
func Load() (*Config, error) {
|
|
libDir := os.Getenv("LIBRARY_DIR")
|
|
dataDir := os.Getenv("DATA_DIR")
|
|
|
|
if libDir == "" || dataDir == "" {
|
|
return nil, errors.New("must set LIBRARY_DIR and DATA_DIR in env")
|
|
}
|
|
|
|
return &Config{
|
|
BaseDir: libDir,
|
|
DBPath: dataDir + "/YaBL.db",
|
|
}, nil
|
|
}
|