30 lines
647 B
Go
30 lines
647 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
)
|
|
|
|
// Config contains all needed configurations
|
|
type Config struct {
|
|
DatabaseUser string
|
|
DatabaseHost string
|
|
DatabasePassword string
|
|
DatabaseName string
|
|
}
|
|
|
|
// LoadConfig from path
|
|
func LoadConfig() (*Config, error) {
|
|
configuration := Config{
|
|
DatabaseUser: os.Getenv("BUDGETEER_DB_USER"),
|
|
DatabaseHost: os.Getenv("BUDGETEER_DB_HOST"),
|
|
DatabasePassword: os.Getenv("BUDGETEER_DB_PASS"),
|
|
DatabaseName: os.Getenv("BUDGETEER_DB_NAME"),
|
|
}
|
|
|
|
if configuration.DatabaseName == "" {
|
|
configuration.DatabaseName = "budgeteer"
|
|
}
|
|
|
|
return &configuration, nil
|
|
}
|