26 lines
347 B
Go
26 lines
347 B
Go
package config
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
)
|
|
|
|
type Config struct {
|
|
BaseDir string
|
|
DBPath string
|
|
}
|
|
|
|
func Load() (*Config, error) {
|
|
dir := os.Getenv("BASE_PATH")
|
|
db := os.Getenv("DB_LINK")
|
|
|
|
if dir == "" || db == "" {
|
|
return nil, errors.New("must set BASE_PATH and DB_LINK in env")
|
|
}
|
|
|
|
return &Config{
|
|
BaseDir: dir,
|
|
DBPath: db,
|
|
}, nil
|
|
}
|