blob: d135fcb0cbb31578aefe3fbf1bd502db7d97ced6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package conf
import (
"log"
"os"
"github.com/BurntSushi/toml"
)
type Conf struct {
DbAdapter string `toml:"DB_ADAPTER"`
DbUser string `toml:"DB_USER"`
DbPassword string `toml:"DB_PASS"`
}
func Load() *Conf {
filepath := os.Getenv("NEWSSTAND_CONFIG_PATH")
if filepath == "" {
workingdir, err := os.Getwd()
if err != nil {
log.Fatal(err)
}
filepath = workingdir + "/.newsstandrc.toml"
}
log.Printf("Config file path: %s", filepath)
var c Conf
_, err := toml.DecodeFile(filepath, &c)
if err != nil {
log.Fatalln(err)
}
log.Println(c.DbAdapter)
return &c
}
|