Cosmos-Server/src/config.go

24 lines
516 B
Go
Raw Permalink Normal View History

2023-02-26 22:26:09 +00:00
package main
import (
"encoding/json"
2023-03-25 20:15:00 +00:00
"github.com/azukaar/cosmos-server/src/utils"
2023-02-26 22:26:09 +00:00
)
2023-03-10 20:59:56 +00:00
func LoadConfig() utils.Config {
2023-04-27 18:29:26 +00:00
config := utils.ReadConfigFromFile()
2023-02-26 22:26:09 +00:00
// check if config is valid
utils.Log("Validating config file...")
2023-04-27 18:29:26 +00:00
err := utils.Validate.Struct(config)
if err != nil {
utils.Fatal("Reading Config File: " + err.Error(), err)
}
2023-03-10 20:59:56 +00:00
utils.LoadBaseMainConfig(config)
configJson, _ := json.MarshalIndent(config, "", " ")
utils.Debug("Loaded Configuration " + (string)(configJson))
2023-03-10 20:59:56 +00:00
2023-02-26 22:26:09 +00:00
return config
}