config and templates
This commit is contained in:
parent
cdf42b7ff3
commit
fb22f599ad
22 changed files with 816 additions and 38 deletions
31
config.go
Normal file
31
config.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"time"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
||||
//go:embed config.default.toml
|
||||
var defaultConfig string
|
||||
|
||||
var config struct {
|
||||
Database struct {
|
||||
File string
|
||||
}
|
||||
|
||||
Server struct {
|
||||
Addr string
|
||||
ReadHeaderTimeout time.Duration
|
||||
RequestTimeout time.Duration
|
||||
}
|
||||
}
|
||||
|
||||
func loadConfig() {
|
||||
_, err := toml.Decode(defaultConfig, &config)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_, _ = toml.DecodeFile("config.toml", &config)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue