Switched to purer libraries
This commit is contained in:
parent
8fa8bb4c3a
commit
9496947f01
21 changed files with 390 additions and 316 deletions
40
config.go
40
config.go
|
|
@ -1,6 +1,42 @@
|
|||
package main
|
||||
|
||||
type FileConfiguration struct {
|
||||
LogFile string
|
||||
import (
|
||||
// Standard
|
||||
"encoding/json"
|
||||
"os"
|
||||
)
|
||||
|
||||
type DatabaseDetails struct {
|
||||
Host string
|
||||
Port int
|
||||
Name string
|
||||
Username string
|
||||
Password string
|
||||
}
|
||||
|
||||
|
||||
type Config struct {
|
||||
Network struct {
|
||||
Address string
|
||||
Port int
|
||||
}
|
||||
|
||||
Websocket struct {
|
||||
Domains []string
|
||||
}
|
||||
|
||||
Database DatabaseDetails
|
||||
|
||||
NodataInterval int `json:"nodata_interval"` // in seconds
|
||||
}
|
||||
|
||||
func initConfig(fname string) (cfg Config, err error) {// {{{
|
||||
var data []byte
|
||||
data, err = os.ReadFile(fname)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &cfg)
|
||||
return
|
||||
}// }}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue