58 lines
1.1 KiB
Go
58 lines
1.1 KiB
Go
package bootstrap
|
|
|
|
import (
|
|
"encoding/json"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
var Config bootstrap
|
|
|
|
type bootstrap struct {
|
|
Redis redis `json:"redis"`
|
|
Sqlite sqlite `json:"sqlite"`
|
|
Cloud cloud `json:"cloud"`
|
|
Session session `json:"session"`
|
|
}
|
|
|
|
type redis struct {
|
|
Addr string `json:"addr"`
|
|
Db int `json:"db"`
|
|
Password string `json:"password"`
|
|
}
|
|
|
|
type sqlite struct {
|
|
Path string `json:"path"`
|
|
}
|
|
|
|
type cloud struct {
|
|
ServiceName string `json:"serviceName"`
|
|
Host string `json:"host"`
|
|
RegisterCenter string `json:"registerCenter"`
|
|
RegisterCenterDb int `json:"registerCenterDb"`
|
|
Heartbeat int `json:"heartbeat"`
|
|
}
|
|
|
|
type session struct {
|
|
Addr string `json:"addr"`
|
|
Db int `json:"db"`
|
|
Expires int `json:"expires"`
|
|
Password string `json:"password"`
|
|
Database string `json:"database"`
|
|
Prefix string `json:"prefix"`
|
|
}
|
|
|
|
func init() {
|
|
log.Println("init bootstrap")
|
|
b, err := os.ReadFile("conf/bootstrap.json")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
// var bootstrap bootstrap
|
|
err2 := json.Unmarshal(b, &Config)
|
|
if err2 != nil {
|
|
panic(err2)
|
|
}
|
|
log.Println(Config)
|
|
}
|