Small config and my own little lib.
This commit is contained in:
parent
a2adf8ad67
commit
cb537328ff
3 changed files with 105 additions and 0 deletions
36
config/server.go
Normal file
36
config/server.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package config
|
||||
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
Admin string `toml:"admin"`
|
||||
Views string `toml:"views"`
|
||||
Layouts string `toml:"layouts"`
|
||||
Port string `toml:"port"`
|
||||
|
||||
Database struct {
|
||||
Driver string `toml:"driver"`
|
||||
Url string `toml:"url"`
|
||||
} `toml:"database"`
|
||||
}
|
||||
|
||||
var Settings config
|
||||
|
||||
func Load(path string) {
|
||||
metadata, err := toml.DecodeFile(path, &Settings)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("error loading config.toml: %v", err)
|
||||
}
|
||||
|
||||
bad_keys := metadata.Undecoded()
|
||||
|
||||
if len(bad_keys) > 0 {
|
||||
log.Fatalf("unknown configuration keys: %v", bad_keys);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue