diff options
Diffstat (limited to 'config.go')
-rw-r--r-- | config.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/config.go b/config.go new file mode 100644 index 0000000..a38fd25 --- /dev/null +++ b/config.go @@ -0,0 +1,34 @@ +package main + +import ( + "bufio" + "os" + + "go.lindenii.runxiyu.org/lindenii-common/scfg" +) + +var config struct { + HTTP struct { + Net string `scfg:"net"` + Addr string `scfg:"addr"` + } `scfg:"http"` + DB struct { + Type string `scfg:"type"` + Conn string `scfg:"conn"` + } `scfg:"db"` +} + +func load_config(path string) (err error) { + config_file, err := os.Open(path) + if err != nil { + return err + } + + decoder := scfg.NewDecoder(bufio.NewReader(config_file)) + err = decoder.Decode(&config) + if err != nil { + return err + } + + return nil +} |